System.out.print ("Create a savings account? Enter yes or no: ");
String createSavingsAccount = console.readLine();
if (createSavingsAccount == "yes")
{
System.out.print ("Enter the balance in the savings account: ");
savingsBalance = Double.parseDouble(console.readLine());
}
当我输入yes时,程序会跳过if语句并返回主菜单。如何检查用户输入?
答案 0 :(得分:0)
使用:
if (createSavingsAccount.equals(("yes")){
...
}