You can go through all the answers above to understand why the .add()
is restricted to '>'
, ' extends>'
, and partly to ' super>'
.
But here's the conclusion of it all if you want to remember it, and dont want to go exploring the answer every time:
List extends A>
means this will accept any List
of A
and subclass of A
.
But you cannot add anything to this list. Not even objects of type A
.
List super A>
means this will accept any list of A
and superclass of A
.
You can add objects of type A
and its subclasses.