Given the types List<?>
, List<Object>
, List<? super Number>
, List<Number>
, List<Integer>
, and List<? extends Number>
, I am trying to understand their hierarchy.
I know that List<Integer>
is NOT a subtype of List<Number>
, even though Integer
is indeed a subtype of Number
, so I thought that it was instead a subtype of List<? extends Number>
.
But List<? extends Number>
intuitively seems to be a subtype of List<Number>
, which makes List<Integer>
a descendant of List<Number>
after all, as my idea of it shows:
So, if a type is descended from another, but not directly, is it still a subtype of its ancestor (or I am just wrong in the diagram)? This exercise has also gotten me a bit confused about ?
vs. Object
...actually, it looks like I might have List<Object>
and List<? super Number>
mixed up. I guess one of the biggest questions is, "Is 'everything' an Object
...or is everything a ?
?" Or both...or neither?