I\'m struggling to get my head around this and was wondering if someone could explain the reasons for this.
I have three classes:
class Angel {}
clas
There is a severe understanding as I always did, List super Person>
is introduced to ensure List
and List
can both be passed in as an argument which is the flexibility upper bounded wildcard provides.
But within the method, in your case only Person
or subtype of Person
can be inserted into the list which ensures the list will always contain valid instances.
E.g. if you are passing in a list of Person
, then only Employee
and Person
can be inserted while Employee
will be auto-type-casted to Person
.