Answers for "counting how many letters in a word java"

4

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
0

java get how many letters in a string

String str = "a string";
int length = str.length( ); // length == 8
Posted by: Guest on January-27-2021

Code answers related to "counting how many letters in a word java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language