代码将不会输出正确的字符串
问题描述:
错误是:字符串不== =撤回,无论我放,它只会说,存款。 我想能够使用(撤回)&(存款)。代码将不会输出正确的字符串
import java.util.Scanner;
public class BasicClasses {
public static void main(String[] args) {
System.out.println("Welcome to First National Bank (FNB)");
Scanner Key = new Scanner(System.in);
String Question = Key.nextLine();
BasicClasses flix = new BasicClasses();
System.out.print(" | Withdraw | or | Deposit | [ ");
Scanner Key1 = new Scanner(System.in);
String Which = Key.nextLine();
if(Which == "withdraw") {
System.out.println("|Withdraw| - | How much do you Want to Withdraw?");
} else {
System.out.println("|Deposit| - | How much will you be Depositing?");
}
}
}
答
比较是这样的: if(Which.equals("withdraw"))
日Thnx :),工作完美。 – 2014-09-25 14:28:14