Sudeep Kumar Das

Take an array of Strings input from the user & find the cumulative (combined) length of all those strings.

Java Basic Codes

Explanation

1370    0

import java.util.*;

 

public class Strings {

   public static void main(String args[]) {

     Scanner sc = new Scanner (System.in);

     int size = sc.nextInt();

     String array[] = new String[size];

     int totLength = 0;

 

     for(int i=0; i

       array[i] = sc.next();

       totLength += array[i].length();

     }

 

     System.out.println(totLength);

   }

}



Share:   

More Questions from Java Basic Codes Module 0