java login attempts using for loop

The solution for “java login attempts using for loop” can be found here. The following code will assist you in solving the problem.

int totalAttempts= 3;
private void executeLogin() {

String userNameStr = userNameTF.getText();
String passWordStr = passWordTF.getText();

if (totalAttempts != 0) {
if (userNameStr == “temp” && passWordStr == “pass”) {
System.out.println(“Correct”);
else {
System.out.println(“Incorrect”);
totalAttempts–;

} else {
System.out.println(“Maximum number of attempts exceeded”);
}
}

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

0
inline scripts encapsulated in