Here you can find the source of removeElement(Class
@SuppressWarnings("unchecked") public static <T> T[] removeElement(Class<T> kind, T[] array, T element)
//package com.java2s; import java.lang.reflect.Array; public class Main { @SuppressWarnings("unchecked") public static <T> T[] removeElement(Class<T> kind, T[] array, T element) { if (array != null) { final int length = array.length; for (int i = 0; i < length; i++) { if (array[i] == element) { if (length == 1) { return null; }//from www.j a va 2 s . c o m T[] result = (T[]) Array.newInstance(kind, length - 1); System.arraycopy(array, 0, result, 0, i); System.arraycopy(array, i + 1, result, i, length - i - 1); return result; } } } return array; } }