What is/are the difference(s) between comparator and comparable in Java?
Comparator is present in java.Util package and Comparable is present in java.lang Package.
Comparator consists of int Compare(Object o1, Object o2)and Comparable consists of int CompareTo(Object o).
In case of Comparable Sorting, logic must be in the same class whose objects are to be sorted whereas in case of Comparator sorting, logic is in separate class.