我有以下的類結構。泛型忽略混淆
public abstract class X { }
public class Y extends X { }
我要做到以下幾點:
public abstract class Action {
public abstract <T extends X> void execute(T t);
}
public class SomeAction extends Action {
public void execute(Y y) { }
}
編譯器是給我以下錯誤:
The Type
SomeAction
must implement the inherited abstract methodAction.execute(T)
我要覆蓋,但我想要的參數是X
的一個子類。
我在這裏做錯了什麼?
謝謝,它做到了:) – AM01