I have a couple of questions about generic wildcards in Java:
What is the difference between List extends T>
and List super
Josh Bloch also has a good explanation of when to use super
and extends
in this google io video talk where he mentions the Producer extends
Consumer super
mnemonic.
From the presentation slides:
Suppose you want to add bulk methods to
Stack
void pushAll(Collection extends E> src);
– src is an E producer
void popAll(Collection super E> dst);
– dst is an E consumer