博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

1.FunctionalInterface

Posted on 2017-05-21 14:21  huiGod  阅读(240)  评论(0)    收藏  举报

The @FunctionalInterface is new annotation in java8.To invoke the function interface's method can be replaced by lambda expression.There is :

1.A functional interface has exactly one abstract method.(the method extends of Object will not be counted)

2.If this interface annotate @FunctionalInterface,there must be varified by definition of functional interface.Or error.

3.If the interface satisfy above first condition without @FunctionalInterface, However, this interface will also be considered as functional interface.

 

In java8:

There are default and static methods in interface since java8.So the Class that implement interface will possess capacity of these these methods. Join this startegy can be compatible with old implemented method.

There is a crurial difference that the type of lambda expression in traditional language (scala,kotlin...) is function.But it's object in java8.