end of day, done till 13
This commit is contained in:
34
experiments/exp12.java
Normal file
34
experiments/exp12.java
Normal file
@@ -0,0 +1,34 @@
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user