Java count the words in string

www‮‬.lautturi.com
Java count the words in string
/**
 * @author lautturi.com 
 * Java example:  java count word in string
 */

import java.util.*;

public class Lautturi {
	public static void main(String[] args) {
		String str = "hello lautturi java world!";

		int words = str.split(" ").length;

		System.out.println("The number of words in the string :" + words);
	}
}

output:

The number of words in the string :4
Created Time:2017-10-01 15:16:54  Author:lautturi