I have a couple of questions about generic wildcards in Java:
What is the difference between List extends T>
and List super
Generic wildcards are created to make methods that operate on Collection more reusable.
For example, if a method has a parameter List
, we can only give List
to this method. It is a waste for this method's funtion under some circumstances:
List
, then we should be allowed to give List
to this method. (Because A-sub IS a A)List
, then we should be allowed to give List
to this method. (Because A IS a A-super)