Amazon interview question

java function to find the word count on a string