1. <? Extends hero>
ArrayList herolist<? Extends hero> indicates that this is a Hero generic or its subclass generic
The generics of the herolist may be hero
The generics of the herolist may be Aphero
The generics of the herolist may be Adhero
So it is hard to be sure that the objects taken out of the herolist can be transformed into hero.
But, you can't put things inside, because
It's not enough to put Aphero <ADHero>
Put Adhero and not satisfied <APHero>
2. <? Super hero>
ArrayList herolist<? Super Hero> indicates that this is a Hero generic or its parent generic type
The generics of the herolist may be hero
Herolist generics may be object
You can insert a subclass of hero and hero inside.
But it's risky to take out, because I'm not sure if it's hero or object.
3. Generic wildcard characters?
Generic wildcard characters? Represents any generic type
Since it represents any generic type, in other words, what generics are possible in this container
So it can only be taken out in the form of an object.
And you can't put objects in it, because you don't know what a generic container is.
JAVA generic wildcard characters? The usage of EXTENDS SUPER