在:泛型與延伸
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