- Sunday, 31 July 2005 20:33
Comparable is an interface that an object can implement to compare itself with other object. If the return value is negative, that means it is less than the input object. If the return value is 0, that means it is equals to the input object, etc.
Comparator is an interface that an object can implement to compare with TWO other objects. If the return value is negative, that means object one is less than object two. If the return value is 0, that means object one is equals to object tow, etc.
We can use utility method in Collections class to do sorting with a comparator.