public class wordsinstring
{
public static void main(String args[])
{
String str="India is a really fast growing economy";
System.out.println(str);
int count=1;
int len=str.length();
for(int i=0;i<len;i++)
{
if(str.charAt(i)==' ')
{
count++;
}
}
System.out.println("The string contains "+count+ " words.");
}
}