Untitled Document

Subscribe here to get updates on new Videos


41. Differences between Comparable and Comparator?




previous homenext


Comparable Comparator
1. It is meant for default natural sorting order. 1. It is meant for customized sorting order.
2. Present in java.lang.package 2. Present in java.util package
3. This interface defines only one method compareTo(). 3. This interface defines two methods compare() and equals().
4.All wrappers classes and String class implement comparable interface. 4. The only implemented classes of Comparator are collator and RuleBasedCollator