Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static boolean hasUpperCase(String str) throws PasswordUpperCase
- {
- boolean hasUpperCase = false;
- //checks the password for an upper case letter
- for (char c : str.toCharArray())
- {
- if(Character.isUpperCase(c))
- {
- hasUpperCase = true;
- }
- }
- if (!hasUpperCase)
- {
- throw new PasswordUpperCase();
- }
- }
- /*************OR************/
- public static boolean hasUpperCase(String str) throws PasswordUpperCase
- {
- boolean hasUpperCase = false;
- //checks the password for an upper case letter
- for (int c = 0; c < str.length() && !hasUpperCase; c++)
- {
- if(Character.isUpperCase(c))
- {
- hasUpperCase = true;
- }
- }
- if (!hasUpperCase)
- {
- throw new PasswordUpperCase();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment