Definition

Java Comparator

Contributor(s): Matthew Haughn

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.io.Serializable, 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 Java Development Tools

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

File Extensions and File Formats

Powered by:

SearchSoftwareQuality

SearchHRSoftware

SearchSAP

SearchERP

Close