How to validate passwords in Java?

Write java code to validate the password using following rules: Length should be between 6 to 20 characters. If the password is as per the given rules return 1 else return -1.If the return value is 1 then print valid password else print as the invalid password.
For More Information Please Refer:


You May Also Like to Read: