public abstract class AbstractTool<AT extends AbstractThing> {
protected ArrayList<AT> ledger;
public AbstractTool() {
ledger = new ArrayList<AT>();
}
public AT getToolAt(int i) {
return ledger.get(i);
}
// More code Which operates on Ledger ...
}
public class Tool<AT extends AbstractThing> extends AbstractTool {
public Tool() {
super();
}
}
如何正确调用 super 将AT
泛型传递Tool
给 AbstractTool 构造函数?
似乎无论我AT
在声明Tool
(Say, Tool<Thing>
) 时选择什么,我总是得到一个AbstractThing
而不是Thing
. 这似乎违背了泛型的目的......
帮助?