We can import Scanner from Java.utils.Scanner to pull in text entered in the console.
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String password = "";
do {
System.out.print("Enter your password: ");
password = sc.nextLine();
if(!password.equals("pals") {
System.out.println(\\Incorrect Password. Try again.");
}
} while(!password.equals("pals");