in this Link, it is declared that we can not create an array of parameterzide type. Create an Array of Arraylists
but in java reflect, we can call getConstructors() method and save it's returned objects as below.
Constructor<?>[] constructors = MyClass.class.getConstructors();
so the question is, isn't it also a parameterized type object ?
Constructor<?>[]
if yes, then why does it work here ?
Good question. You can surely define an array of parameterized type bye breaking type safety like,
Arrays are covariant subtypes, which means Strings [] is a subtype of Object [] and are implemented in way that the elements we are adding is checked at runtime for there types like,
To prevent wrong assignments, compiler does runtime checks of every array assignment.
while generics are compile time only. So Java would not be able to identify generic type once aliased to subtype, like,
Unbounded wildcard type is only way as while putting the elements, no real type check is required for unbounded wildcard type.
Hope this answers your question.