我尝试继承一个接口,该接口包含接收另一个对象的方法equals,但在类中,我尝试使用类类型,例如:class grade,并用grade other重写该方法。如果我错了,请纠正我,任何类都继承自java中的对象类。我可能不太了解接口。谢谢!
public interface Comparable {
int Bigger(String ... args);
boolean Equals(Object other);
}
@Override
public boolean Equals(Grade other) {
if(other.getGrade() == this.getGrade() && other.getPoints() == this.getPoints() && other.getSubject() == this.getSubject())
return true;
return false;
}
2条答案
按热度按时间kknvjkwl1#
使用泛型:
bbmckpt72#
忘记了泛型编程,