jenny
Posts : 5 Points : 9 Reputation : 0 Birthday : 1994-07-05 Join date : 2011-09-22 Age : 29 Location : canlubang ,laguna Job/hobbies : texting,drinking w/my friends
| Subject: import java Mon Jan 30, 2012 8:07 am | |
| - Quote :
- import java.util.*;
class listExample{ public static void main (String args[],String sortedlist){ 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);
}
} }
| |
|