Write a java program to convert all the elements of the array into lowercase. Write a program to accept a string array as input, convert all the elements into lowercase and sort the string array. Display the sorted array.
Input and Output Format:
Input consists of a an integer which denotes the size of the array followed by the array of strings,
Output consists of a string array.
Refer sample output for formatting specifications.
Sample Input 1:
5
AAA
BB
CCCC
A
ABCDE
Sample Output 1:
a
aaa
abcde
bb
cccc
java program to convert all the elements of the array into lowercase
import java.util.*;
public class Main {
/**
* @param args
* @throws ParseException
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String s1[]={"AAA","BB","CCCC","A","ABCDE"};
String s2[]=new String[s1.length];
for (int i = 0; i < s1.length; i++)
{
s2[i]=s1[i].toLowerCase();
}
Arrays.sort(s2);
for (int i = 0; i < s2.length; i++) {
System.out.println(s2[i]);
}
}
}