39 lines
916 B
Java
39 lines
916 B
Java
//12 write a java program for sorting arrayList
|
|
import java.util.*;
|
|
|
|
public class SortingArray
|
|
{
|
|
public static void main(String[] args)
|
|
{
|
|
ArrayList<String> StationList = new ArrayList<>();
|
|
|
|
StationList.add("Panvel");
|
|
StationList.add("Khandeshwar");
|
|
StationList.add("Mansarover");
|
|
StationList.add("Kharghar");
|
|
StationList.add("Belapur");
|
|
StationList.add("Seawoods");
|
|
StationList.add("Nerul");
|
|
StationList.add("Juinagar");
|
|
StationList.add("Sanpada");
|
|
StationList.add("Vashi");
|
|
StationList.add("Mankhurd");
|
|
|
|
System.out.println("Unsorted List: \n");
|
|
Iterator pre = StationList.iterator();
|
|
while(pre.hasNext())
|
|
{
|
|
System.out.println(pre.next());
|
|
}
|
|
|
|
Collections.sort(StationList);
|
|
System.out.println("\nSorted List: \n");
|
|
|
|
Iterator post = StationList.iterator();
|
|
while(post.hasNext())
|
|
{
|
|
System.out.println(post.next());
|
|
}
|
|
|
|
}
|
|
} |