Why do we really need Comparator in Java? [closed]

A class can only have one compareTo method but you can define as many comparators as you like for it. This is useful to define different orderings which is not such an uncommon requirement.

Leave a Comment