I have a question about this method from java.util.Collections
:
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 understand how <? super T>
works, however, I don't understand why the first parameter is List<? super T>
instead of List<T>
. I think it's useless in this situation.
Using List<T>
should work as well, shouldn't it?
Could you give me some examples to understand it if possible, please?
Thanks.