Why does Comparator declare equals?

后端 未结 8 1531
无人及你
无人及你 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:47

    From the Java documentations, the reason why Comparator has it's own equals() method:

    However, overriding this method may, in some cases, improve performance by allowing programs to determine that two distinct comparators impose the same order.

提交回复
热议问题