当前位置:网站首页>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

边栏推荐
- antd组件upload上传xlsx文件,并读取文件内容
- Local dealers play the community group purchase mode and share millions of operations
- Il n'est pas nécessaire d'appuyer longtemps sur la fonction de démarrage pour modifier Jelly [chapitre]
- 手写ORM(对象关系映射)增删改查
- Golang's learning route
- How does Jerry test the wrong touch rate of keys [chapter]
- [LeetCode] 反转字符串【344】
- uniapp微信登录返显用户名和头像
- 数据分析学习记录--用EXCEL完成简单的单因素方差分析
- 悬镜安全在RSAC2022上斩获Global InfoSec Awards四项大奖
猜你喜欢

泛型与反射,看这篇就够了

Qt QScrollArea

Local dealers play the community group purchase mode and share millions of operations
![[chestnut sugar GIS] ArcScene - how to make elevation map with height](/img/91/f3df0a7633263c6264cb5c27eb149f.png)
[chestnut sugar GIS] ArcScene - how to make elevation map with height

创新实力再获认可!腾讯安全MSS获2022年度云原生安全守护先锋

Mask R-CNN

Learning records of data analysis (II) -- simple use of response surface method and design expert

Uniapp wechat login returns user name and Avatar

Array advanced improvement

解决Chrome浏览器和Edeg浏览器主页被篡改的方法
随机推荐
Rails 3 activerecord: sort by association count - rails 3 activerecord: order by count on Association
杰理之充电拔出,无法触摸开机【篇】
Jerry's built-in shutdown current is 1.2ua, and then it can't be turned on by long pressing [chapter]
Webrtc audio and video capture and playback examples and mediastream media stream analysis
Go multithreaded data search
Jatpack------LiveData
Golang的学习路线
地方经销商玩转社区团购模式,百万运营分享
Comprehensively analyze the logic of the shared purchase business model? How sharing purchase empowers Enterprises
Golang's learning route
Tronapi-波场接口-源码无加密-可二开--附接口文档-基于ThinkPHP5封装-作者详细指导-2022年7月1日08:43:06
Learning records of data analysis (II) -- simple use of response surface method and design expert
数据分析学习记录(二)---响应曲面法及Design-Expert的简单使用
手写ORM(对象关系映射)增删改查
分布式监控系统zabbix
数据标注典型案例,景联文科技如何助力企业搭建数据方案
Graphic view frame
Using rendertext() to output multiple lines of text with rendertext() in R shiny
pytorch训练CPU占用持续增长(bug)
悬镜安全在RSAC2022上斩获Global InfoSec Awards四项大奖