1

Comparable and Comparator are Functional Interface and Comparator is declared as @FunctionalInterface also but why Comparable is not declared as @FunctionalInterface in jdk 1.8 though it is one of them?

example: enter image description here

Christian Will
  • 1,529
  • 3
  • 17
  • 25
iamgul
  • 83
  • 9

1 Answers1

6

Comparable is technically a functional interface, but it makes no sense to actually implement it with a lambda. Comparable objects really have to have other state that you're trying to compare, and you're supposed to compare two objects of the same type. Neither of those make sense for a lambda.

Louis Wasserman
  • 191,574
  • 25
  • 345
  • 413