For instance, this works,
public staticV wrapper(V v, Class clazz){
return v;
}
int i = wrapper(1, Integer.class);
But this is not compilable,
public staticV[] wrapperArray(V[] v, Class clazz){
return v;
}
int[] i2 = wrapperArray(i2, int.class);
int.class will be auto-converted to Integer.class but int[] will not. I can't find the exact line in JLS describing this, do leave a comment if you could.
No comments:
Post a Comment