Why Functional Interfaces in Java 8 have one Abstract Method?

后端 未结 3 1726
时光取名叫无心
时光取名叫无心 2020-11-28 11:13

As we know in Java 8, the concept of functional interfaces are introduced. A Functional Interface has one abstract method and several default or static methods

3条回答
  •  不知归路
    2020-11-28 11:37

    The functional interface also known as Single Abstract Method Interface was introduced to facilitate Lambda functions. Since a lambda function can only provide the implementation for 1 method it is mandatory for the functional interface to have ONLY one abstract method. For more details refer here.

    Edit -> Also worth noting here is that, a functional interface can have a default implementation in the interface. You will find a lot more details on the implementation on the link above.

提交回复
热议问题