I have some code here that should ask the user to input a 'password' that will be checked in my second class. My issue is that the program won't pass through into the method in my second class (PasswordChecker), how would I fix this? I assume it is something to do with the line:
blnPassword2 = PasswordChecker.PasswordCheck(PasswordGuess);
import java.util.Scanner;
public class PasswordGuesser {
public static void main(String[] args){
boolean blnPassword2;
Scanner keyboard = new Scanner(System.in);
String PasswordGuess = keyboard.nextLine();
blnPassword2 = PasswordChecker.PasswordCheck(PasswordGuess);
if (blnPassword2==true) {
System.out.println("Password correct");
}
else
{
System.out.println("Password incorrect");
}
}
}
public class PasswordChecker {
public static boolean PasswordCheck(String PasswordGuess){
boolean blnPassword;
String StrPassword = "Enter";
if (PasswordGuess==StrPassword) {
blnPassword = true;
}
else {
blnPassword = false;
}
return (blnPassword);
}
}
Thank you,
Jason Wren