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
Read its javadoc. It's there only to explain what equals()
must return if you choose to override it in a class implementing Comparator. You might think that no comparator can be equal to any other, but it's not the case. You might think that two comparators are equal if they return the same thing for any arguments, but it's not the case. The javadoc explains that two comparators are equal if they impose the same ordering, whatever the arguments given. The javadoc also says:
Note that it is always safe not to override Object.equals(Object)
Most of the time, you don't override equals()
in comparators.