当前位置:网站首页>Lambda expression: an article takes you through
Lambda expression: an article takes you through
2022-07-02 22:59:00 【Xiaopucai learns Java】
One ,JDK8 introduce Lambda expression
JDk1.8 in the future Interface can There are common ways , It's not just abstract methods , The method is default Embellished , And this method , His implementation subclasses can call this method .
Define common methods in the interface , It is generally used to modify the shortcomings of the previous version . Developers can hardly use .
dafault Keyword represents a common method in an interface , Don't omit .
Two , Functional interface : An interface has and has only one abstract method , It's a functional interface .
Use @FunctionalInterface To check whether it is a functional interface , There can only be one , No more , Not without it
1, Through anonymous inner classes , To implement functional interfaces
2,Lambda expression , To implement the interface
3、 ... and ,lambda expression
Lambda Expressions are based on functions and interfaces , If there are multiple interfaces or no interfaces , You won't find the abstract methods in the interface one by one .Lambda The expression will become error prone .
It is the implementation that only retains the parameters and body of the method .
Lambda Four forms of expressions :
1, No return value , No parameter
2, No return value, parameter
3, With return value and no parameter
4, No return value no parameter
Four ,Lambda Features of expressions :
1, If the implementation of a method has only one line of code , It can be omitted {}
2, If method has only one parameter , Then brackets can be omitted
3, You can omit the types of expression parameters ( Or omit it all , Or don't omit it all )
4, If the method body has a return value and the method body has only one line , It can be omitted {},return
边栏推荐
- 数据分析学习记录(二)---响应曲面法及Design-Expert的简单使用
- 严守工期,确保质量,这家AI数据标注公司做到了!
- 大话云原生之负载均衡篇-小饭馆客流量变大了
- 全面解析分享购商业模式逻辑?分享购是如何赋能企业
- 傑理之修改不需要長按開機功能【篇】
- [chestnut sugar GIS] ArcScene - how to make elevation map with height
- Rails 3 activerecord: sort by association count - rails 3 activerecord: order by count on Association
- Hanging mirror security won four global infosec awards on rsac2022
- 创新实力再获认可!腾讯安全MSS获2022年度云原生安全守护先锋
- mysql重置密码,忘记密码,重置root密码,重置mysql密码
猜你喜欢
P1007 single log bridge
Hanging mirror security won four global infosec awards on rsac2022
Share 10 JS closure interview questions (diagrams), come in and see how many you can answer correctly
牛客网:最大子矩阵
P7072 [csp-j2020] live broadcast Award
Qt QScrollArea
Jielizhi, production line assembly link [chapter]
【硬件】标准阻值的由来
百度智能云-创建人脸识别应用
Kubernetes uses the host name to allocate the pod on the specified node
随机推荐
Using rendertext() to output multiple lines of text with rendertext() in R shiny
Jerry's prototype will trigger shutdown after multiple touches [chapter]
[羊城杯2020]easyphp
Stop slave is stuck -- the event of the transaction is not copied completely
Storage unit conversion
Golang's learning route
杰理之修改不需要长按开机功能【篇】
Rails 3 activerecord: sort by association count - rails 3 activerecord: order by count on Association
Go multithreaded data search
[Solved] Splunk: Cannot get username when all users are selected“
Go语言sqlx库操作SQLite3数据库增删改查
AES高级加密协议的动机阐述
How can I use knockout's $parent/$root pseudovariables from inside a . computed() observable?
2016. 增量元素之间的最大差值
QT qsplitter splitter
P7072 [CSP-J2020] 直播获奖
最小生成树 Minimum Spanning Tree
[error record] the flutter reports an error (could not read script 'xxx\flutter\u tools\gradle\app\u plugin\u loader.gradle')
创新实力再获认可!腾讯安全MSS获2022年度云原生安全守护先锋
go 多线程数据搜索