Exercise 4.15: wordCount
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 (any character other than ' '). For example, the call
wordCount("hello") should return
1, the call
wordCount("how are you?") should return
3, the call
wordCount(" this string has wide spaces ") should return
5, and the call
wordCount(" ") should return
Contacting server and running tests...
Is there a problem?
Contact a Practice-It administrator.