如果我有类名SavingsAccount,两个实例变量,例如私有(private)双余额和私有(private)双 利息那么我如何编写一个具有initialBalance和利息的构造函数?
最佳答案
public class SavingsAccount {
private double balance;
private double interest;
public SavingsAccount(double balance, double interest) {
this.balance = balance;
this.interest = interest;
}
}
关于java - SavingsAccount 构造函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26122668/