当前位置:网站首页>The difference between lambda and anonymous inner class
The difference between lambda and anonymous inner class
2022-07-03 12:17:00 【Early summer 0811】
1. The required parameter types are inconsistent
Anonymous inner class parameters can be classes , abstract class , Interface ;
lambda Parameters in can only be interfaces
2. The number of abstract methods is inconsistent
Abstract methods in anonymous inner classes can be one or more , No fixed restrictions
lambda There can only be one abstract method in the interface of
3. The implementation principle is different
Anonymous inner classes are generated after recompilation .class file
lambda It is generated dynamically at runtime .class
summary :
When there is only one abstract method in the interface , It is recommended to use lambda expression , It simplifies the code , But when there are multiple abstract methods , You can only use anonymous inner classes to implement the specific method .
边栏推荐
- Flutter: self study system
- 实现验证码验证
- 102. Sequence traversal of binary tree
- If you can't learn, you have to learn. Jetpack compose writes an im app (II)
- [MySQL special] read lock and write lock
- Solution à la défaillance de l'installation d'Electron
- Wechat applet - basic content
- JVM内存模型
- 347. Top k high frequency elements
- (construction notes) learn the specific technology of how to design reusable software entities from three levels: class, API and framework
猜你喜欢

2.7 overview of livedata knowledge points

C language improvement article (wchar_t) character type

PHP导出word方法(一mht)

Shardingsphere sub database and sub table < 3 >

MCDF Experiment 1

Unity3d learning notes 5 - create sub mesh

Php Export word method (One MHT)

【mysql官方文档】死锁

Shutter: add gradient stroke to font

Flutter 退出登录二次确认怎么做才更优雅?
随机推荐
PHP导出word方法(一phpword)
在网上炒股开户可以吗?资金安全吗?
Vulnhub's Nagini
Redis
Oracle advanced (I) realize DMP by expdp impdp command
How to deploy web pages to Alibaba cloud
Quantitative calculation research
手机号码变成空号导致亚马逊账号登陆两步验证失败的恢复网址及方法
Shutter: overview of shutter architecture (excerpt)
Atomic atomic operation
2.7 overview of livedata knowledge points
2.6 preliminary cognition of synergetic couroutines
If you can't learn, you have to learn. Jetpack compose writes an im app (II)
Adult adult adult
(构造笔记)ADT与OOP
temp
Symlink(): solution to protocol error in PHP artisan storage:link on win10
If you can't learn, you have to learn. Jetpack compose writes an im app (I)
Shell: basic learning
Pragma pack syntax and usage