†`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: Activity 3 e2 yung gwa ko paltan nyo nlng mga fruits! Mon Jan 30, 2012 8:20 am | |
| - Quote :
import java.util.*; class lito{ public static void main (String args[]){ List sortedList=new LinkedList(); sortedList=new LinkedList(); sortedList.addAll(Arrays.asList(new String []{"Apple","Orange","Grapes","Mango","Lemon","Water Melon","Atis","Pineapple","Guava","Guyabano"}));
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);
}
} }
e2 output nan ! - Quote :
run: Sorted:[Apple, Atis, Grapes, Guava, Guyabano, Lemon, Mango, Orange, Pineapple, Water Melon] Reverse:[Water Melon, Pineapple, Orange, Mango, Lemon, Guyabano, Guava, Grapes, Atis, Apple] Shuffle:[Guava, Orange, Lemon, Apple, Pineapple, Atis, Guyabano, Mango, Grapes, Water Melon] After insertion:[Guava, Orange, Lemon, Apple, Pineapple, Atis, Guyabano, Mango, Grapes, RMB, Water Melon] BUILD SUCCESSFUL (total time: 0 seconds)
| |
|