public static void hasUpperCase(String str) throws PasswordUpperCase { boolean hasUpperCase = false; //checks the password for an upper case letter for (int c = 0; c < str.length() && Character.isUpperCase(c); c++) { if(Character.isUpperCase(c)) { hasUpperCase = true; } } if (!hasUpperCase) { throw new PasswordUpperCase(); } }