我在netbeans ubuntu java standart項目(測試準備)上編寫程序。 當我創建AccountStudent.java我得到錯誤。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 - 錯誤:無法找到符號:構造帳戶()
public class AccountStudent extends Account{
}
修正了problem-加空賬構造:
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++;
}
}
爲什麼要我創建,如果已經存在,他是因爲他繼承Object類的空構造帳戶?
感謝
這錯誤應該被改寫,以在有意義 – TheLQ 2010-08-17 23:29:17
@Micheal:有錯字錯誤。公共帳戶(字符串所有者){超級(所有者);}應該是公共AccountStudent(字符串所有者){超級(所有者);}。 – Shashi 2010-08-18 15:08:34
@Shashi:謝謝,更正 – 2010-08-18 16:06:16