MyClass e = new MyClass();
List<Object> ok = new ArrayList<Object>();
List<? extends Object> ko = new ArrayList<Object>();
ok.add(e);
ko.add(e); // doesn't compile
为什么它不编译?MyClass
是Object
...的子类
有关信息,我收到以下消息:
The method add(capture#1-of ? extends Object) in the type List<capture#1-of ? extends Object> is not applicable for the arguments (MyClass)