Why does Comparator declare equals?

后端 未结 8 1533
无人及你
无人及你 2021-02-05 04:34

The Comparator interface has its own equals() method. Any class will get equals() by default through Object class. What is the need to have equal

8条回答
  •  野性不改
    2021-02-05 04:51

    from the docs:

    it is always safe not to override Object.equals(Object). However, overriding this method may, in some cases, improve performance by allowing programs to determine that two distinct comparators impose the same order.

提交回复
热议问题