Write a method called wordCount that accepts a String as its parameter and returns the number of words in the String. A word is a sequence of one or more nonspace characters
It should be easy with:
String[] arr = "how are you sir".split("\\s"); System.out.printf("Count [%d]%n", arr.length);