当前位置:网站首页>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
边栏推荐
- Jerry's charge unplugged, unable to touch the boot [chapter]
- 杰理之内置短按再长按,不管长按多长时间都是短按【篇】
- How can I use knockout's $parent/$root pseudovariables from inside a . computed() observable?
- 数据分析学习记录--用EXCEL完成简单的单因素方差分析
- 分布式监控系统zabbix
- [leetcode] there are duplicate elements [217]
- Jerry's prototype has no touch, and the reinstallation becomes normal after dismantling [chapter]
- [leetcode] number of palindromes [9]
- stop slave卡住--事务的事件没有复制完整
- 杰理之快速触摸不响应问题【篇】
猜你喜欢
随机推荐
How can I use knockout's $parent/$root pseudovariables from inside a . computed() observable?
PMP项目整合管理
Jielizhi, production line assembly link [chapter]
Solve the error of changing the selected file when uploading excel file. Net:: err_ UPLOAD_ FILE_ CHANGED
小鹏P7出事故,安全气囊未弹出,这正常吗?
用sentinel熔断比例阈值改不了,设置慢调用比例没效果
海思3559万能平台搭建:在截获的YUV图像上画框
Golang面试整理 三 简历如何书写
boot actuator - prometheus使用
antd组件upload上传xlsx文件,并读取文件内容
[leetcode] most elements [169]
Tronapi-波场接口-源码无加密-可二开--附接口文档-基于ThinkPHP5封装-作者详细指导-2022年7月1日08:43:06
Splunk audit 的设定
Mask R-CNN
Jerry's built-in short press and long press, no matter how long it is, it is a short press [chapter]
Jerry's fast touch does not respond [chapter]
泛型与反射,看这篇就够了
景联文科技低价策略帮助AI企业降低模型训练成本
[leetcode] reverse the word III in the string [557]
位的高阶运算