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
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
Environmental Sciences,
1 day ago
Math,
2 days ago
CBSE BOARD X,
2 days ago
Physics,
8 months ago
Economy,
8 months ago