I have the following code in Java:
public static<T> void doIt(Class<T> t) { T[] arr; arr = (T[])Array.newInstance(t, 4); }
I want to be able to use doIt using both a primitive type, such as double, and using class objects such as String.
I could do this using (code compilation):
doIt(double.class); doIt(String.class);
However, I am worried that in the first case, the Java compiler will actually wrap the double primitive type using the Double class, which I don't want. I really want it to create a primitive array in this case (when creating an instance of an array of objects with a String case). Does anyone know what happens with doIt (double.class)? Is this an instance of Double or double?
Thanks.
kloop source share