我有一个界面HTTPSequence
。我还有一个抽象类AbstractHTTPFactory
,它又具有一个返回的抽象方法ArrayList<HTTPSequence>
。在派生的类中,AbstractHTTPFactory
我想重写这些方法以返回ArrayList<[Class implementing HTTPSequence]>
。
可能吗 ?现在编译器给了我一个错误,建议我将覆盖的方法签名更改为HTTPSequence
.
// abstract class with abstract method returning ArrayList of objects implementing interface
abstract public class AbstractHTTPFactory {
abstract ArrayList<HTTPSequence> make();
}
// Specific class that returns ArrayList of objects of the class implementing HTTPSequence
public class RecipesHTTPFactory extends AbstractHTTPFactory{
public ArrayList<Recipe> make() {
}
}
// interface
public interface HTTPSequence {
}
// one of the classes implementing the above interface
public class Recipe implements HTTPSequence {
}
Eclipse 给我的信息是:
此行有多个标记 - 返回类型与 AbstractHTTPFactory.make() 不兼容 - 实现 ....ider.AbstractHTTPFactory.make