【发布时间】:2014-01-14 20:56:19
【问题描述】:
我在 netbeans ubuntu java 标准项目(测试准备)上编程。 当我创建 AccountStudent.java 时出现错误。
Account.java
public abstract class Account {
protected double _sum;
protected String _owner;
protected static int accountCounter=0;
public Account(String owner){
this._sum=0;
this._owner=owner;
accountCounter++;
}
}
AccountStudent.java- 错误:找不到符号:构造函数 Account()
public class AccountStudent extends Account{
}
修复问题 - 添加空 Account 构造函数:
Account.java
public abstract class Account {
protected double _sum;
protected String _owner;
protected static int accountCounter=0;
public Account(){
}
public Account(String owner){
this._sum=0;
this._owner=owner;
accountCounter++;
}
}
如果他已经存在,我为什么要创建空的构造函数 Account,因为他继承了 Object 类?
谢谢
【问题讨论】:
标签: java inheritance