Computer Science, asked by christinalaventer, 2 days ago

Define a class to accept and store 10 Strings into an array. Find and display the length of each element in the array.​

Answers

Answered by samarthkrv
1

Answer:

import java.util.*;

public class Main

{

public static void main(String[] args) {

 Scanner sc = new Scanner(System.in);

 System.out.println("Enter all 10 strings-");

 String[] arr = new String[10];

     for(int i = 0; i < 10; i++){

         arr[i] = sc.nextLine();

     }

     for(int i = 0; i < 10; i++){

         System.out.println("The length of " + arr[i] + " is " + arr[i].length());

     }

}

}

Explanation:

Similar questions