Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

How do you count characters in a string array in Java?

package practical5;

import java.util.Arrays;

public class Part1_9 {

public static void main(String[] args) {

    // declaring and populating array
    String quoteArray[] = { ""Continuous", "effort", "not", "strength",
            "nor", "intelligence", "is", "the", "key", "to", "unlocking",
            "our", "potential."
" };

    // for loop to print full array
    for (int counter = 0; counter < quoteArray.length; counter++) {
        System.out.print(quoteArray[counter] + " ");
    }// end of for loop

    // Printing array using Enhanced for/ for each loop (Different way to
    // print array)
    for (String element : quoteArray) {
        System.out.print(element + " ");
    }// end of enhanced for

    // line break
    System.out.println();

    // printing number of words in array
    System.out.println("Number of words in array: " + quoteArray.length);

    **// printing total number of letters in array**
    for (int counter = 0; counter < quoteArray.length; counter++) {
        String letters = new String(quoteArray[counter]);
    }

    // printing the smallest word

    // printing the biggest word

}// end of main

}// end of class
Comment

PREVIOUS NEXT
Code Example
Java :: convert array of char to string java 
Java :: richest customer wealth 
Java :: how to check if user is logged in firebase android and then load another activity 
Java :: generate uuid from string 
Java :: what is transient in java 
Java :: remove last character from stringbuffer 
Java :: how to add spaces before string in java 
Java :: Quick Sort Java Implementation 
Java :: rider find and replace 
Java :: What is the way to use profiles to configure the environment-specific configuration with Spring Boot? 
Java :: how to put string in char array in java tutorialspoint 
Java :: copying primitive array to arraylist in java 
Java :: button change text java 
Java :: splay tree java implementation 
Java :: throw and throws keyword in java 
Java :: create a hashmap 
Java :: java string character at index 
Java :: java list last element 
Java :: java hashmap time complexity 
Java :: declare generic set java 
Java :: is it possible to quick sort a string in java 
Java :: how to get index of arraylist in java 
Java :: priority queue java comparator 
Java :: How to return the elements of a matrix in spiral order, in Java? 
Java :: final vs static keyword in java 
Java :: creating an array list in java 
Java :: text field mouse event java 
Java :: how to change resource color to int color in android 
Java :: ClassNotFoundException: org.springframework.ui.freemarker.FreeMarkerConfigurationFactory 
Java :: object creation in java 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =