我正在努力实现下一个目标:
家长:
public class Animal {
private List<Animal> relatives;
public List<Animal> getRelatives() {
return relatives;
}
public void setRelatives(List<Animal> relatives) {
this.relatives = relatives;
}
}
孩子:
public class Dog extends Animal {
private List<Dog> relatives;
public List<Dog> getRelatives() {
return relatives;
}
public void setRelatives(List<Dog> relatives) {
this.relatives = relatives;
}
}
但由于某种原因,我收到方法冲突的错误。这是否可以通过继承而不使用泛型类型来实现?
郎朗坤
杨魅力
相关分类