brainfrz

Untitled

Mar 1st, 2016
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. public static boolean hasUpperCase(String str) throws PasswordUpperCase
  2. {  
  3.     boolean hasUpperCase = false;
  4.  
  5.     //checks the password for an upper case letter
  6.     for (char c : str.toCharArray())
  7.     {
  8.         if(Character.isUpperCase(c))
  9.         {
  10.             hasUpperCase = true;
  11.         }
  12.     }
  13.    
  14.     if (!hasUpperCase)
  15.     {
  16.         throw new PasswordUpperCase();
  17.     }
  18. }
  19.  
  20. /*************OR************/
  21.  
  22. public static boolean hasUpperCase(String str) throws PasswordUpperCase
  23. {  
  24.     boolean hasUpperCase = false;
  25.  
  26.     //checks the password for an upper case letter
  27.     for (int c = 0; c < str.length() && !hasUpperCase; c++)
  28.     {
  29.         if(Character.isUpperCase(c))
  30.         {
  31.             hasUpperCase = true;
  32.         }
  33.     }
  34.    
  35.     if (!hasUpperCase)
  36.     {
  37.         throw new PasswordUpperCase();
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment