In Java we can use a Comparable or Comparator interface to sort a collection. Both interfaces have some differences you should know in order for you to make the right decision. Comparable Interface We can only sort the collection by a single member of an element. Comparable affects the current object being sorted. Override compareTo() …
Continue reading “Java Collections: Comparable vs Comparator”