Comparable VS Comparator in Java.

Java util package provides us number of sorted data structures; one of those is the TreeSet. TreeSet is an implementation of Set and it stores the elements in sorted order. All elements needs to be added into a TreeSet should implement Comparable interface directly or indirectly or the TreeSet should be constructed with an appropriate [...]
Continue reading…