I am trying to learn Java Generics wildcard by reading the following:
http://www.angelikalanger.com/GenericsFAQ/FAQSections/TypeArguments.html#FAQ103
There is one example in the material:
public class Collections {
public static <T> void copy (List<? super T> dest, List<? extends T> src) {
for (int i=0; i<src.size(); i++)
dest.set(i,src.get(i));
}
}
I was wondering if I can change the method signature as the following:
public static <T> void copy(List<? super T> dest, List<? extends T> src) {
↓
public static <T> void copy(List<T> dest, List<? extends T> src) {
Are there any differences between these two method sinatures?
Examples would be appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…