我看不出这个短课的问题。我得到8个类,接口或枚举预期错误。感谢
public class BankAccount {
public BankAccount {
private double balance = 0;
}
public BankAccount(double balanceIn) {
private double balance = balanceIn;
}
public double checkBalance {
return balance;
}
public void deposit(double amount) {
if(amount > 0) balance += amount;
}
public void withdraw(double amount) {
if(amount <= balance) balance -= amount;
}
}
答案 0 :(得分:2)
您在构造函数中声明了修饰符和字段。把它放在ctor外面
public BankAccount(double balanceIn) {
private double balance = 0;
}
应该是
public class BankAccount
{
private double balance = 0;
public BankAccount(){}
}
public BankAccount {
private double balance = 0;
}
也错了..它不是你缺少()和删除
的构造函数private double balance = 0;