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