2 回答
TA贡献1921条经验 获得超9个赞
问题就在这里,所以你输入的密码等于密码。
input = JOptionPane.showInputDialog(" What is the password please ?");
passWord = String.valueOf(input);
你需要像这样修改它:
input = JOptionPane.showInputDialog(" What is the password please ?");
String inputPassWord = String.valueOf(input);
while (!inputPassWord.equalsIgnoreCase(passWord))
{
input = JOptionPane.showInputDialog(" What is the password please ?");
inputPassWord = String.valueOf(input);
}
TA贡献1830条经验 获得超9个赞
您正在使用password包含实际密码的相同变量。下面的逻辑应该可以解决你的问题,
String passWord = "PROSPERO" ;
String inputPassword="";
inputPassword = JOptionPane.showInputDialog(" What is the password please ?");
while (!inputPassword.equalsIgnoreCase(passWord)) {
inputPassword = JOptionPane.showInputDialog(" What is the password please ?");
}
添加回答
举报