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 primitive type such as double and using class objects such as String.
I could do it by using (code compiles):
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 a Double class, which I don't want. I actually want it to instantiate a primitive array in this case (while instantiating an objects array with the String case). Does someone know what happens with doIt(double.class)? Is it instantiated as Double or double?
Thanks.