FunctionalInterface Comparator has 2 abstract methods
equals()
is not an abstract method. This method overrides Object.equals(Object)
, and is there only for the Comparator interface to be able to have javadoc attached to the method, explaining how comparators should implement equals()
.
See the javadoc of FunctionalInterface:
If an interface declares an abstract method overriding one of the public methods of java.lang.Object, that also does not count toward the interface's abstract method count since any implementation of the interface will have an implementation from java.lang.Object or elsewhere.
equals() is inherited from Object, and inherited public methods are not counted when you’re determining whether an interface is a functional interface. So even though equals() is abstract in Comparator, because it’s inherited, it doesn’t count.
RULE: A functional interface is an interface that has one abstract method. Default methods don’t count; static methods don’t count; and methods inherited from Object don’t count.