1 String name = "Carmen is a fantastic play"; //arbitrary sentence
2
3 int numWords = (name.split("\\s+")).length; //split string based on whitespace
4 //split returns array - find legth of array
5
6 System.out.println(numWords);