Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

no of words in a string in java

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.");
        
        
    } 
}
Comment

PREVIOUS NEXT
Code Example
Java :: How to find the maximum occurring character in a given String? using hashmap java 
Java :: keep jframe on top 
Java :: exceptions in java 
Java :: osmdroid get current zoom level 
Java :: how to spilt the string with comma in jaav 
Java :: rename action bar android 
Java :: dockerfile spring boot 
Java :: how to create Java ArrayList 
Java :: generate random number using math.random in java 
Java :: app not showing in share menu android 
Java :: how to check when edittext clicked android 
Java :: Data provider using junit 
Java :: module java.base does not "opens java.io" to unnamed module 
Java :: java new string 
Java :: how to remove letters from string java 
Java :: java swing border 
Java :: enable cors on apache tomcat 
Java :: java zahlen runden auf 1 nachkommastelle 
Java :: sort arrays by first element java 
Java :: How to efficiently find the diameter of a binary tree, in Java? 
Java :: t implements comparable 
Java :: how to insert a 0 in an array java 
Java :: how to make a rest api in spring 
Java :: stringbuilder java setlength 
Java :: LRU Cache java 
Java :: flutter doctor Unable to find bundled Java version. 
Java :: MD5 java 
Java :: input arraylist in java 
Java :: Java Expression statements 
Java :: convert string into unicode java 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =