Here you can find the source of removeElement(final E[] array, final int index)
@SuppressWarnings("unchecked") public static <E> E[] removeElement(final E[] array, final int index)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Main { @SuppressWarnings("unchecked") public static <E> E[] removeElement(final E[] array, final int index) { final List<E> list = new ArrayList<>(Arrays.asList(array)); list.remove(index);//from w w w . j ava 2s .c om return list.toArray((E[]) new Object[list.size()]); } public static int[] removeElement(final int[] input, final int index) { final List<Integer> result = new ArrayList<>(); for (int i = 0; i < input.length; i++) { if (i != index) { result.add(input[i]); } } return toIntArray(result); } public static int[] toIntArray(final List<Integer> list) { final int[] ret = new int[list.size()]; for (int i = 0; i < ret.length; i++) { ret[i] = list.get(i); } return ret; } }