public class User {
}
public class Child extends User {
}
import java.util.LinkedList;
public class Test {
public static void main(String[] args) {
LinkedList<? super Child> linkedList = new LinkedList<>();
linkedList.add(new Child());
linkedList.add(new User());
/**
* 上面添加User报错
* The method add(capture#2-of ? super Child) in the type LinkedList<capture#2-of ? super Child> is not applicable for the arguments (User)
*/
}
}
蓝山帝景
神不在的星期二
随时随地看视频慕课网APP
相关分类