A DESCRIPTION OF THE REQUEST :
It is impossible to write programs/classes that implement generic type arrays.
For exemple, we can't make such a class:
public class myGenericClass<T> {
private T[] genericArray;
public myGenericClass (int length) {
T = new T[length]; // genereic type arrays not allowed
}
}
JUSTIFICATION :
It is really frustrating !
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expect the following line of code to be valid:
T = new T[length];
ACTUAL -
The following line of code is not valid:
T = new T[length];
---------- BEGIN SOURCE ----------
public class myGenericClass<T> {
private T[] genericArray;
public myGenericClass (int length) {
T = new T[length]; // genereic type arrays not allowed
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
I don't like this "workaround", but here it is:
public class myGenericClass<T> {
private T[] genericArray;
public myGenericClass (int length) {
T = (T[])new Object[length]; // casting an Object[] to a T[]
}
}