public static void main(String[] args) {
String str ="Hello World";
String[] words = str.split("s");
int wordCount= 0;
int i, wordsSize= words.length;
for(i=0; i<wordsSize; ++i)
if(words!=null && !"".equals(words))
++wordCount;
System.out.println("Word count="+wordCount);
}}
String str ="Hello World";
String[] words = str.split("s");
int wordCount= 0;
int i, wordsSize= words.length;
for(i=0; i<wordsSize; ++i)
if(words!=null && !"".equals(words))
++wordCount;
System.out.println("Word count="+wordCount);
}}