在:泛型与延伸
public class Organic<E> {
void react(E e) {
}
static void main(String[] args) {
Organic<? extends Elem> compound = new Organic<Elem>();
compound.react(new Elem());
}
}
class Elem {}
为什么我得到下面的编译错误?
方法
react(capture#1-of ? extends Elem)
在类型Organic<capture#1-of ? extends Elem>
不适用于参数(Elem
)
为什么你使用不同的参数为变量声明和对象实例?你想达到什么目的? – biziclop 2012-03-23 11:35:59
我不想实现任何目标。这只是一本书的练习。 – 2012-03-26 07:45:45