public class StringSample {
  public static void main(String[] args) {
       restOf(restOf(restOf("cowboy")));
       int x=55;
       System.out.println(restOf(String.valueOf(x)));
       String sentence = "The name is James Bond,  BOnd";
       
       // use indexOf to get the next space, and then check if next character
       // is capital.
       int count=0;
       int loc=0;
       if (Character.isUpperCase(sentence.charAt(0)))
           count++;
       loc = sentence.indexOf(' ', 0);
       while(loc!=-1) {
         System.out.println("loc is: " + loc + " charAt loc is: " + sentence.charAt(loc));
         loc = sentence.indexOf(' ', loc+1);
             if (loc!=-1)
                if (Character.isUpperCase(sentence.charAt(loc+1)))
                    count++;
       }
       System.out.println(count);
       // use for loop to iterate through each char in the string
       count=0;
       if (Character.isUpperCase(sentence.charAt(0)))
           count++;
       for (int i=0; i<sentence.length()-1; i++)
           if (sentence.charAt(i)==' ' && Character.isUpperCase(sentence.charAt(i+1)))
                 count++;
                
       System.out.println(count);
       moreThanOnce("dabcdd", 3);
  }
  public static String restOf(String s) {
         return s.substring(1);   
  }
  /*3B on Sample Final. Return true if any of the first n characters appear
   * more than once in the string. **/
  public static boolean moreThanOnce(String str, int n) {
    for (int i=0; i<n; i++)
      if (str.indexOf(str.charAt(i),i+1)!=-1) {
          System.out.println("YES");
          return true;
      }
    System.out.println("NO");
    return false;
  }
 }
