The two interfaces are used for object sorting. well, i want to know they follow which sorting mechanism(algorithm). i guess insertion sorting. please can anyone give light on this ?
They are just interfaces, which allows to determine the natural order of the compared objects. The comparing algorithm is in the class doing the actual comparision. For example, java.util.Collections.sort(). The API says : The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n log(n) performance. This implementation dumps the specified list into an array, sorts the array, and iterates over the list resetting each element from the corresponding position in the array. This avoids the n2log(n) performance that would result from attempting to sort a linked list in place.
Well Chrishtope, but merge sort needs two list[or array] , then it will sort and merge those two into one list. but here i have only one list which has the objects need to be sort. in this case you mean Collections class (sort()) use the merge sort?