Java Comparator

Java Comparator is an interface for sorting Java objects. Invoked by “java.util.comparator,” Java Comparator compares two Java objects in a “compare(Object 01, Object 02)” format.

Using configurable methods, Java Comparator can compare objects to return an integer based on a positive, equal or negative comparison. Since it is not limited to comparing numbers, this can allow Java Comparator to be set up to order lists alphabetically or numerically. With, Java comparator can also be used to successfully order serialized data structures.

Java Comparator is similar to the Comparable interface but is intended for defining alternate sort orders where Comparable sorts by natural ordering such as lexicographic sorting.

This was last updated in July 2016

Continue Reading About Java Comparator

Dig Deeper on Development tools for continuous software delivery

App Architecture
Software Quality
Cloud Computing