I am trying to create a small program that reads a password and determines if it is a password you can use. I was using matches() to see if it has at least one letter (uppercase or lowercase) and one digit as well as be 6 characters long. I try to use matches like this:
if ( passwordLength >= 6
&& password.matches("[A-Za-z]")
&& password.matches("\\d")
) {
System.out.println("Valid Password.");
}
else {
System.out.println("Invalid Password.");
}
Im not sure what i am doing wrong. Please help.