code: private int countUpper(String str) {
          if (str == null)
              return 0;
          int num = 0;
          for (int i = 0; i < str.length(); i++)
              if (Character.isUpperCase(str.charAt(i)))
                  num++;
          return num;
      }
docs: Count number of upper case chars.