3

As per my understanding "A functional interface is an interface that has just one abstract method"

But when I looked into the source code of Comparator.class file, i can see two methods,

 int compare(T o1, T o2);
 boolean equals(Object obj);

Could you please explain how Comparator interface is functional interface?

How do we use Comparator in lambda expression?

Edit: I understand from some of the answers below, that those methods are coming from Object method. Then what is the method which comparator interface actually has.

How Compiler knows this method is from Object class and need to be overridden?

Kannan Thangadurai
  • 1,117
  • 2
  • 17
  • 36
  • 1
    equals method doesnt count since that is taken from Object... – ΦXocę 웃 Пepeúpa ツ Dec 13 '17 at 06:41
  • *How Compiler knows this method is from Object class...?* It's not a secret which methods are defined in the Object class. You can look it up yourself: https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html – shmosel Dec 14 '17 at 07:27

0 Answers0