Hello
I followed a conference about java generics at Devoxx. The person who gave the presentation was a prof. at the university of Leuven, Belgium. He told that you can't create an array of generics. Let me give an example.
|
Code:
|
T [] names = new T[10]; |
The new T[10] part gives the error. That's something I don't understand. The T in this piece of code is replaced by the name of the class during the compiling. So this should change to this for example:
|
Code:
|
String [] names = new String[10]; |
So during runtime this creates a array holding Strings. I understand that you can't do the follow thing because you don't know the constructor of T.
Can someone explain why I can't create a generic array. Thanks!