+ 25
Java Generics - Array Restrictions
I cannot instantiate an array whose base type is a type parameter. why? Here, I've written the problem: https://code.sololearn.com/cdMeKYymB6L4
5 odpowiedzi
+ 18
Arun Tomar : I changed the code as you said but again there is a exception.
+ 6
Amir
you did a very small mistakes bro..
MyClass<?> myClasses[] = new
MyClass<?>[20];
this is work fine
becoause of the
parametrised constructor
in MyClass
but
In class Gen
by default
there is default constructor
and you try to access the parameterised constructor
that you not created
...
i hope you understand now
try to used javap decompiler of java
you understand alot
+ 4
Amir
yes you change..
but the way you cheated the array of generics type is wrong mam..
i comments also.
i hope you go through it
+ 2
It's a well-known platform where you can earn or hire
https://www.freelancer.com/get/davarak
- 1
java is itself a creation of classes in terms of constructor as same as class before you can use it .it should be declared and initialized first .i hope you understand my point