public class HelloWorld{
public static void main(String[] args) {
List<? extends Number> callback = new ArrayList<Long>();
new Container<>().test(callback);
}
public static class Container<T extends Number> {
public void test(List<T> some) {
}
}
}
this code produces
HelloWorld.java:7: error: incompatible types: List<CAP#1> cannot be converted to List<Number>
new Container<>().test(callback);
^
where CAP#1 is a fresh type-variable:
CAP#1 extends Number from capture of ? extends Number
Can you explain in details this code incorrect.
I expect that new Container will be generalized with type compatible with callback