程序跳过if语句

时间:2015-01-16 23:59:08

标签: java

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语句并返回主菜单。如何检查用户输入?

1 个答案:

答案 0 :(得分:0)

使用:

if (createSavingsAccount.equals(("yes")){
...
}