为什么即使与我输入的密码相同,我的密码也显示错误? 密码是通过的,我写了密码,但它告诉我这是错误的。
import java.util.Scanner;
public class App
{
public static void main(String[] args)
{
System.out.println("Guess the word: ");
Scanner test = new Scanner(System.in);
String guessThePassword = test.nextLine();
System.out.println("You wrote: " + guessThePassword);
String correctPasswordIs = "pass";
System.out.println("The correct password is: " + correctPasswordIs);
if (guessThePassword == correctPasswordIs)
{
System.out.println("The password you wrote is right");
}
else
{
System.out.println("The password you wrote is wrong");
}
test.close();
}
}