Comparable is an interface providing the natural ordering on the implemented objects. List and arrays of them can be sorted automatically by using Collections.sort(List) and Arrays.sort(Object[]) methods

Comparator is a comparison functional interface passed to a sort method as Collections.sort(List, Comparator) or Arrays.sort(Object[], Comparator) to control over the sort order or to provide an ordering for collections of objects that don't have a Comparable natural ordering

Let's define two object classes (one implements Comparable interface and one doesn't) and implement two unit test classes to see the difference in practice



The above compareTo method provides the default / natural order in ascending to ComparableBook objects. If you want the default order in descending, try below

@Override
public int compareTo(ComparableBook o) {  
    return o.title.compareTo(this.title);
}

Comparable examples


Comparator examples