Answers for "Find word and count in a scentence in java"

3

count the number of words in a string java

public static void main(String[] args)
    { 
        //return the number of words in a string 
        
       String example = "This is a good exercise"; 
       
       int length = example.split(" ").length;
       
       System.out.println("The string is " + length + " words long.");
        
        
    }
Posted by: Guest on June-04-2020

Code answers related to "Find word and count in a scentence in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language