0

Assuming we have this hierarchy of classes.

Object <-- Class A <-- Class B <-- Class C

If I have

List<? super B> myList = new ArrayList<>();

Why can I only add objects to "myList" which are Instance of class B or the subclass C? That doesn't make any sense to me. I thought if I use "? super B" in my wildcard (or the same with generics) I can only put in objects which are B or super classes of B. I'm absolutely confused and I hope someone can help me to understand this stuff.

Nazaret K.
  • 3,409
  • 6
  • 22
  • 31
Mathew
  • 1
  • 1

0 Answers0