|
|
|
|
The Comparator interface is for imposing an ordering in the case where you might wish to compare two objects that do not implement the Comparable interface (or even on objects that do, if you wish).
Comparator defines the following methods:
As with the Comparable compareTo method, the Comparator compare method returns:
The equals method may or may not need to be implemented in the class that implements Comparator, because the Object class implements such an equals method, which suffices for most purposes. However, you may wish to override this method to improve performance by allowing programs to determine that two distinct Comparators impose the same order.
|
|
This page was last modified on 02 October, 2007 |