<T extends Number> void m1(List<T> list) {
list.add(list.get(0));
}
void m2(List<? extends Number> list) {
list.add(list.get(0));
}
I found difficult to understand the difference between above two methods.
First method m1()
compiles successfully, but method m2()
produces a compiler error:
The method
add(capture#1-of ? extends Number)
in the typeList<capture#1-of ? extends Number>
is not applicable for the arguments(capture#2-of ? extends Number)