//: generics/ArrayMaker.java import java.lang.reflect.*; import java.util.*; public class ArrayMaker { private Class kind; public ArrayMaker(Class kind) { this.kind = kind; } @SuppressWarnings("unchecked") T[] create(int size) { return (T[])Array.newInstance(kind, size); } public static void main(String[] args) { ArrayMaker stringMaker = new ArrayMaker(String.class); String[] stringArray = stringMaker.create(9); System.out.println(Arrays.toString(stringArray)); } } /* Output: [null, null, null, null, null, null, null, null, null] *///:~