If I am entering the password which is not equal to the string "kiran", the program should keep on ask me to enter the correct password. But in the code that I am showing it is not doing that. Please correct my code as I believe that I am doing something wrong. Please correct me without using any other concept such as do-while.
public class WhilePrac {
public static void main(String args[]) {
String password;
Scanner s = new Scanner(System.in);
System.out.println("Enter Password");
password = s.nextLine();
while (password.matches("[^kiran]"))
{
System.out.println("Enter the correct password");
}
}
}