†`Li†o`† Admin
Posts : 80 Points : 168 Reputation : 9 Birthday : 1995-11-16 Join date : 2011-08-31 Age : 28 Location : Mayapa Calamba Laguna Job/hobbies : Playing Computer Games.
| Subject: 2nd Activity ListExample Mon Jan 30, 2012 8:19 am | |
| - Quote :
- import java.util.*;
class listExample{ public static void main (String args[]){ List sortedList=new LinkedList(); sortedList=new LinkedList(); sortedList.addAll(Arrays.asList(new String []{"Bong","Ren","Nat"}));
Collections.sort(sortedList); System.out.println("Sorted:"+sortedList); Collections.reverse(sortedList); System.out.println("Reverse:"+sortedList); Collections.shuffle(sortedList); System.out.println("Shuffle:"+sortedList);
int index=Collections.binarySearch(sortedList,"RMB"); if (index<0){ sortedList.add(-index-1,"RMB"); System.out.println("After insertion:"+sortedList);
}
} } | |
|