34 lines
832 B
Java
34 lines
832 B
Java
|
|
import java.util.*;
|
||
|
|
|
||
|
|
public class exp12{
|
||
|
|
public static void main(String[] args){
|
||
|
|
ArrayList<String> playerList = new ArrayList<String>();
|
||
|
|
playerList.add("Sachin Tendulkar");
|
||
|
|
playerList.add("Rahul Dravid");
|
||
|
|
playerList.add("Virender Sehwag");
|
||
|
|
playerList.add("MS Dhoni");
|
||
|
|
playerList.add("Virat Kohli");
|
||
|
|
playerList.add("Anil Kumble");
|
||
|
|
playerList.add("Yuvraj Singh");
|
||
|
|
playerList.add("Kapil Dev");
|
||
|
|
playerList.add("Sunil Gavaskar");
|
||
|
|
playerList.add("Javagal Srinath");
|
||
|
|
|
||
|
|
|
||
|
|
System.out.println("Unsorted List: \n");
|
||
|
|
Iterator pre = playerList.iterator();
|
||
|
|
while(pre.hasNext()){
|
||
|
|
System.out.println(pre.next());
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
Collections.sort(playerList);
|
||
|
|
System.out.println("\nSorted List: \n");
|
||
|
|
|
||
|
|
Iterator post = playerList.iterator();
|
||
|
|
while(post.hasNext()){
|
||
|
|
System.out.println(post.next());
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|