可能重复:
Java String.equals 与 ==
主要代码:
String pass = getPassowrd();
if(pass == "hi"){
System.out.println("Correct Password");
loggedin = true;
new Home();
}else{
System.out.println("Incorrect Password");
}
获取密码代码:
private static String getPassword() {
java.util.Scanner keyboard = new java.util.Scanner(System.in);
return keyboard.nextLine();
}
我究竟做错了什么?
谢谢,艾萨克