title: Count amount of words in a string without any loops
body: <p>For example you send a string "Yo what’s up dog?" to a function, the function returns 4 counts.</p>
  
  <p>below is what I wrote:</p>
  
  <pre><code>public class CountString {
      public int count(String str){
          int count=0;
          for(int i=0; i&lt;str.length();i++){
              if(str.charAt(i) == ' ')
                  count++;
          }
          System.out.printf("\n number of strings: "+ (count+1));
          return count+1;
      }
  }
  </code></pre>
  
  <p>Are there any other faster methods? Now how do you perform the same job without including any loops (for, while, do-while)? </p>