Notice: session_start(): A session had already been started - ignoring in /home/u614325693/domains/onedoubt.com/public_html/post.php on line 3
Count Words - ONEDOUBT.COM

Java How To Count Words


Count Number of Words in a String

You can easily count the number of words in a string with the following example:

Example

String words = "One Two Three Four";
int countWords = words.split("\s").length;
System.out.println(countWords);



Login
ADS CODE