我有接口:Java泛型方法覆蓋
public interface CartService extends RemoteService{
<T extends ActionResponse> T execute(Action<T> action);
}
我想重寫 '執行' 方法實現:類型的 的方法執行(GetCart)XX:
public class XX implements CartService {
@Override
public <GetCartResponse> GetCartResponse execute(GetCart action) {
// TODO Auto-generated method stub
return null;
}
}
但是編譯器錯誤必須覆蓋或實施超類型方法
GetCart & GetCartResponse:
public class GetCart implements Action<GetCartResponse>{
}
public class GetCartResponse implements ActionResponse {
private final ArrayList<CartItemRow> items;
public GetCartResponse(ArrayList<CartItemRow> items) {
this.items = items;
}
public ArrayList<CartItemRow> getItems() {
return items;
}
}
如何覆蓋此方法?
@blackliteon:您是否嘗試過'公共 GetCartResponse執行(GetCart動作)'? –
bguiz
2010-05-05 13:21:44