I'm trying to make the incorrect password start the loop over until the right password is inputted (which it does) but System.out.println statements repeat infinitely in the console. A break statement just terminates the code, but I want it to keep going except only printing the statements once. Any solutions?
public static void main(String[] args){
System.out.println("What is the password?");
Scanner passwordScan = new Scanner(System.in);
String pass = passwordScan.nextLine();
String password = "JohnnyRoberts123";
while(password != pass) {
System.out.println("Wrong password!");
System.out.println("Try again, what is the password?");
continue;