Java Comparator and Comparable demystified

Java comparator and java comparable both achieve the same thing, helps to sort objects and both are Interfaces. Let us first explore comparable ( java.lang.comparable) and then comparator ( java.util.Comparator ). Comparable Quick facts: Belongs to java.lang  package and has a single method int compareTo(T o).  The… Read More