Comparator (Java SE 26 & JDK 26)
- Type Parameters:
T- the type of objects that may be compared by this comparator
- All Known Implementing Classes:
Collator, RuleBasedCollator
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
-
Method Summary
intCompares its two arguments for order.
comparing(Function<? super T, ? extends U> keyExtractor) Accepts a function that extracts a
Comparablesort key from a typeT, and returns aComparator<T>that compares by that sort key.comparing(Function<? super T, ? extends U> keyExtractor, Comparator<? super U> keyComparator) Accepts a function that extracts a sort key from a type
T, and returns aComparator<T>that compares by that sort key using the specifiedComparator.Accepts a function that extracts a
doublesort key from a typeT, and returns aComparator<T>that compares by that sort key.Accepts a function that extracts an
intsort key from a typeT, and returns aComparator<T>that compares by that sort key.Accepts a function that extracts a
longsort key from a typeT, and returns aComparator<T>that compares by that sort key.booleanIndicates whether some other object is "equal to" this comparator.
default <U extends T>
Umax(U o1, U o2) Returns the greater of two values according to this comparator.
default <U extends T>
Umin(U o1, U o2) Returns the smaller of two values according to this comparator.
Returns a comparator that compares
Comparableobjects in natural order.Returns a null-friendly comparator that considers
nullto be less than non-null.Returns a null-friendly comparator that considers
nullto be greater than non-null.reversed()Returns a comparator that imposes the reverse ordering of this comparator.
Returns a comparator that imposes the reverse of the natural ordering.
Returns a lexicographic-order comparator with another comparator.
thenComparing(Function<? super T, ? extends U> keyExtractor) Returns a lexicographic-order comparator with a function that extracts a
Comparablesort key.thenComparing(Function<? super T, ? extends U> keyExtractor, Comparator<? super U> keyComparator) Returns a lexicographic-order comparator with a function that extracts a key to be compared with the given
Comparator.Returns a lexicographic-order comparator with a function that extracts a
doublesort key.Returns a lexicographic-order comparator with a function that extracts an
intsort key.Returns a lexicographic-order comparator with a function that extracts a
longsort key.
-
Method Details
-
compare
-
equals
-
reversed
-
max
-
min
-
thenComparing
-
thenComparing
-
thenComparing
-
thenComparingInt
-
thenComparingLong
-
thenComparingDouble
-
reverseOrder
-
naturalOrder
-
nullsFirst
-
nullsLast
-
comparing
-
comparing
-
comparingInt
-
comparingLong
-
comparingDouble
-