Need <? super T> type in Collections.copy
Signature of the Collections.copy method,
public static <T> void copy(List<? super T> dest, List<? extends T> src) Just wondering if dest needs to be <? super T> <? super T> , not just <T> ?
public static void main(String[] args) { simpleCopy(new ArrayList<Number>(), new ArrayList<Number>()); simpleCopy(new ArrayList<Number>(), new ArrayList<Integer>()); } public static <T> void simpleCopy(Collection<T> dest, Collection<? extends T> src) { for (T element : src) dest.add(element); } +5
No one has answered this question yet.
See similar questions:
or similar: