Here you can find the source of newInstance(Class
@SuppressWarnings("unchecked") public static <T> T[] newInstance(Class<T> arrayComponentClass, T value)
//package com.java2s; // This package is part of the Spiralcraft project and is licensed under import java.lang.reflect.Array; public class Main { /**/*from www.j av a 2 s .c o m*/ * Create single element array of the specified class which contains the * specified value */ @SuppressWarnings("unchecked") public static <T> T[] newInstance(Class<T> arrayComponentClass, T value) { T[] array = (T[]) Array.newInstance(arrayComponentClass, 1); array[0] = value; // Array.set(array,0,value); return array; } }