Implementing an interface with two abstract methods by a lambda expression

前端 未结 4 2069
Happy的楠姐
Happy的楠姐 2020-12-28 13:39

In Java 8 the lambda expression is introduced to help with the reduction of boilerplate code. If the interface has only one method it works fine. I

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-28 14:39

    Lambda expressions can only be used to implement functional interfaces, which are interfaces having a single abstract method. An interface with two abstract methods can't be implemented by a lambda expression.

提交回复
热议问题