Java Generics difference between wildcard and generic parameter type
Could someone explain to me why the third method doesnt compile?
public class Test{
public <K> void test(List<K> list){ //Compiles
K n = list.get(0);
}
public void test(List<? extends Number> list){ //Compiles
Number n = list.get(0);
}
public <K> void test(List<K extends Number> list){ //Doesn't compile !!
Number n = list.get(0);
}
}
No comments:
Post a Comment