gpt4 book ai didi

java - SavingsAccount 构造函数

转载 作者:行者123 更新时间:2023-12-01 12:28:39 25 4
gpt4 key购买 nike

如果我有类名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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com