The context you need to understand is not of Integer
or Number
but it's the List
. Let's suppose you were the one creating the List
class then how would you create the class so it will only support a specific type of class.
Yes, that List
class won't use Object as its type but instead use a wild card ?
.
As documentation of WildCards say
So what is the supertype of all kinds of collections? It's written Collection<?>
(pronounced "collection of unknown")
Same thing can be said for List.
So what is the supertype of all kinds of Lists? It's written List<?>
(pronounced "List of unknown")
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…