This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
i have done this by doing a toArray() on the linked list and then using compareto() for every element in the array, can this be done without using arrays? can i sort this ArrayList of strings only using the Collection class methods?
Originally posted by Shraddha Jain: oh yes! tried this now. but i see there's a method sort(list l ,Comparator c) can i specify how i want sort() to compare objects in the arraylist? using this method?
Collection.sort(List list)will sort in natural order. sort(List list, Comparator c), The the comparator to determine the order of the list.All elements in the list must be mutually comparable.