I have a very basic question ragarding Java generics . I thought that both List<Number> and List<? extends Number> are homogeneous . Am I right or is there something fundamental I am missing ?
I have a very basic question ragarding Java generics . I thought that both
Share
Generic types are more pedantic.
<? extends Number>means Number or an unknown a sub class. If you obtain such a value it will be aNumber, but you cannot give a value of this type because you don’t know which is valid.The difference is in arguments and return values.
superis used in a few places to signify the type can be a super type. e.g.In Collections, this method says the Comparator needs to be able to compare the same type or any super type.
This means you can have