LabWork
This commit is contained in:
39
SortingArray.java
Normal file
39
SortingArray.java
Normal file
@@ -0,0 +1,39 @@
|
||||
//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());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user