In Java 8, the @FunctionalInterface
annotation is introduced to denote any interface that has exactly one abstract method as a functional interface. One of the reason for its introduction is to indicate the user (programmer), that lambda expression can be used in context of a functional interface.
The Comparator
interface is annotated with @FunctionalInterface
. But, two methods are abstract.
int compare(T o1, T o2);
and
boolean equals(Object obj);
In the docs of FunctionalInterface
, it is clearly mentioned as
Conceptually, a functional interface has exactly one abstract method.
Isn't the equals
method not considered as abstract here?