
Describe me below code how this program code is make and work, and those method is use in this why?
import java.util.*;
class SortList
{
public static void main(String[]args)
{
Scanner input=new Scanner(System.in);
System.out.println("Enter the Elements:");
ArrayList<String> List=new ArrayList<String>();
for(i=0;i<5;i++)
{
String st=input.next();
list.add(st);
}
System.out.println("ArrayList Elements in Sorted order:");
Collections.sort(list);
for(int=0;i input
the purpose of education is to replace an empty mind with an open
output.
one
of
education
is
an
empty
an
open

Scanner class allow the user to read input from command prompt. To store the data, an object of ArrayList is created, that will add the list elements using add() method. The method read() reads the string value from the console.We have used for loop to input 5 elements. Now to sort these elements, we have used Collections.sort() method that will sort the list elements alphabetically.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.