Подсчитайте количество слов в струнной Java
public static void main(String[] args)
{
//return the number of words in a string
String example = "This is a good exercise";
int length = example.split(" ").length;
System.out.println("The string is " + length + " words long.");
}
Luc Botes