随着为什么我不能将SuperType添加到列表<T>其中<T扩展了SuperType>?
public class SuperType {
}
和
public class TestClass<T extends SuperType > {
public void doSomething() {
List<T> list = new ArrayList<T>();
list.add(new SuperType()); // ERROR
}
}
不能编译,给我
在类型列表中的方法Add(T)是不适用的参数(超)
但是为什么?