我运行此程序时遇到了问题,如果我使用int它可以工作,但对于字符串,它不会。Java:在字符串问题时执行
import java.util.Scanner;
public class userinput_swutch_do_while {
public static void main(String[] args) {
String password= null;
Scanner value = new Scanner(System.in);
do {
System.out.println("Enter the password for ATM: ");
password = value.nextLine();
System.out.println("You put : "+password);
} while (password !="55");
System.out.println("You got it!");
}
}
的[?我如何在Java中比较字符串(可能的复制http://stackoverflow.com/questions/513832/how-do-i-compare -strings-in-java) –