ERROR:The type Employee must implement the inherited abstract method Person.getDescription()
这个错误是因为你的子类继承的是抽象的父类,但是你的子类并不是定义的抽象的类,所以你要对父类中的抽象的方法进行重新定义,重新定义为非抽象的方法
例如:
abstract class Person{
public abstract String getDescription();
}
class Employee extends Person {
public String getDescription() {
return String.format("an employee with a salary of %.2f", salary);
}
}
本文解释了当子类继承抽象父类时,必须重新定义父类中的抽象方法以避免ERROR:ThetypeEmployeemustimplementtheinheritedabstractmethodPerson.getDescription()这类错误。通过一个具体的例子展示了如何正确地实现抽象方法。
5354

被折叠的 条评论
为什么被折叠?



