私はこれをJavaで書きましたが、ifエラーなしでelseを取得し続けます。私はそれを何度も調べましたが、エラーを見つけることができません。それは本当に欠落しているのか、それともプログラムの残りの問題なのか?
public class Password {
public static void main(String[] args) {
//int Counter = 0;
String[] UserName = {
"William Whitcomb" , "Pamela Healy" ,
"Dennis Clark" , "Troy Bingham" ,
"Bill Mauler"
};
String[] Password = {
"WWhit0523" , "PHeal0854" ,
"DClar1053" , "TBing1272" ,
"BMaul0968"
};
String EnterName = JOptionPane.showInputDialog ( "Enter a valid user name.", //Name pane window
"User Name");
String EnterPassword = JOptionPane.showInputDialog ( "Enter a valid password.", //Age pane window
"Password");
for (int Counter = 0; Counter < UserName.length;){
Validate();
if (Validate() = true) {
JOptionPane.showMessageDialog (null, "You entered the User Name of " + UserName[Counter] +
"and the password of " + Password[Counter]); //Results pane
}
} //End of for
} //End of Method
Boolean Validate(String EnterName , String EnterPassword){
Boolean Condition = false;
if (EnterName.equals(UserName[Counter])) {
if (EnterPassword.equals(Password[Counter])) {
Condition = true;
return //Condition;
} else {
JOptionPane.showMessageDialog (null, "You have entered an invalid password.");
Counter += 1;
} //End of Inner Else
} else {
JOptionPane.showMessageDialog (null, "You have entered an invalid user name.");
Counter += 1;
} //End of Outer Else
} //End of outer if
} //End of Method
} //End of Class