An array of references to a specific generic type is not allowed in Java.
e.g.,
ArrSpec<String> arrs[] = new ArrSpec<String>[10];
is not allowed though the type checkng and memory allocation can be done at the compile time itself.
Instead of this, Java allows to use Wildcard type array of references to a generic type.
e.g.,
ArrSpec<?> arrs[] = new ArrSpec<?>[10];
is allowed though the type checking, memory allocation and any type of values to be stored would be decided at the runtime.
This above behavior is confusing and needs more clarification!


LinkBack URL
About LinkBacks
Reply With Quote