0
所以我有这段代码,我只想要选项2在选项1的值不是0时执行。如果它有0,则抛出一个错误。任何帮助表示赞赏。谢谢! :)如果第一条语句= 0,则不要继续
if (option == 1){
System.out.println("YOU HAVE SELECTED OPTION 1");
System.out.println(accounts[i].getOwner().getfirstName() + " " + accounts[i].getOwner().getlastName() + ", Please enter your yearly salary:");
accounts[i].setyearlySalary(in.nextDouble());
}
else if (option == 2){
System.out.println("YOU HAVE SELECTED OPTION 2");
System.out.println(accounts[i].getOwner().getfirstName() + " " + accounts[i].getOwner().getlastName() + ", Please enter any additional salary:");
accounts[i].setotherSalary(in.nextDouble());
}
你是在做你说什么地方卡住? – emaillenin
我在选项2后尝试了一些if(accounts [I] .setyearlySalary == 0){System.out.println(“错误:如果选项1为零,则无法继续);}但它表示void不能转换为布尔值 – icewolf461
@ icewolf461为什么你在使用setter而不是getter在条件为 “accounts [I] .setyearlySalary == 0”? –