Confusion in the general hierarchy of List <>

Wildcards and Subtyping - Oracle Documentation

This document shows the relationship between several classes of a class declared with both upper and lower bounded wildcards. The connection depicted in the figure below:

Shared Hierarchy

In the right hierarchy, List<? super Number>is a type subtype List<? super Integer>. Doesn't that bother you?

As I understand it, it List<? super Number>can be represented by anyone List<type>, typeanywhere Number, or a superclass Number. The same logic holds for List<? super Integer>. So how to List<? super Number>be a subtype List<? super Integer>?

+4
source share
1

, List<? super Number> Number , List<? super Integer> + .

: , . List<? super Number> List<? super Integer>, .

, , :

enter image description here

+5

Source: https://habr.com/ru/post/1659545/


All Articles