I wanted to check if the password was entered correctly with Scanner in Java.
I tried with this code:
import java.util.Scanner;
public class test {
    public static void main(String[] args) {
        System.out.println("Please enter your username:");
        Scanner username = new Scanner(System.in);
        System.out.println("Hello " + username.nextLine() + ", please authenticate using your password:");
        Scanner password = new Scanner(System.in);
        String pw = "test";
        String pwEnter = password.nextLine();
        if (pw != pwEnter) {
            System.out.println("Sorry, you don't have access to the System.");
        } else {
            System.out.println("Thank you for authenticating, you can proceed with:");
        }
    }
}
 
    