E
- 比较对象类型public class ComparableComparator<E extends Comparable<? super E>> extends Object implements Comparator<E>, Serializable
Comparable
对象的默认比较器Modifier and Type | Field and Description |
---|---|
static ComparableComparator |
INSTANCE
单例
|
Constructor and Description |
---|
ComparableComparator()
构造
|
Modifier and Type | Method and Description |
---|---|
int |
compare(E obj1,
E obj2)
比较两个
Comparable 对象 |
boolean |
equals(Object object) |
int |
hashCode() |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
comparing, comparing, comparingDouble, comparingInt, comparingLong, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
public static final ComparableComparator INSTANCE
public int compare(E obj1, E obj2)
Comparable
对象
obj1.compareTo(obj2)
compare
in interface Comparator<E extends Comparable<? super E>>
obj1
- 被比较的第一个对象obj2
- the second object to compareNullPointerException
- obj1为null
或者比较中抛出空指针异常public boolean equals(Object object)
equals
in interface Comparator<E extends Comparable<? super E>>
equals
in class Object
Copyright © 2021. All rights reserved.