public static Object[] add(Object[] array, Object element) { Object joinedArray; int elementPos; if (array != null) { joinedArray = Array.newInstance(array.getClass().getComponentType(), array.length + 1); System.arraycopy(array, 0, joinedArray, 0, array.length); elementPos = array.length; } else {  joinedArray = Array.newInstance(element != null ? element.getClass() : Object.class, 1); elementPos = 0; } Array.set(joinedArray, elementPos, element); return (Object[]) joinedArray;
public static Object[] add(final Object[] array, final Object element) { Object newArray = copyArrayGrow1(array, element != null ? element.getClass() : Object.class); Array.set(newArray, lastIndex(newArray), element); return (Object[]) newArray;
    public static Object[] add(Object[] array, Object element) {        Object joinedArray;        int elementPos;        if (array != null) {            joinedArray = Array.newInstance(array.getClass().getComponentType(), array.length + 1);            System.arraycopy(array, 0, joinedArray, 0, array.length);            elementPos = array.length;        } else {            // null input array, use the element type            joinedArray = Array.newInstance(element != null ? element.getClass() : Object.class, 1);            elementPos = 0;        }        Array.set(joinedArray, elementPos, element);        return (Object[]) joinedArray;    }