A
Andrea Desole
If I have a generic like
class MyClass<MyType>
it's normal that I can't do something like this:
MyType type = new MyType()
This is because of the type erasure. But what I don't understand is why
Eclipse complains if I do the following:
MyType[] types = new MyType[10]
Apparently I can't create an array of generic types. But why not? What
is the problem? That is just an array of uninitialized objects, type
erasure shouldn't be a problem here, should it?
class MyClass<MyType>
it's normal that I can't do something like this:
MyType type = new MyType()
This is because of the type erasure. But what I don't understand is why
Eclipse complains if I do the following:
MyType[] types = new MyType[10]
Apparently I can't create an array of generic types. But why not? What
is the problem? That is just an array of uninitialized objects, type
erasure shouldn't be a problem here, should it?