当前位置:网站首页>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 .
边栏推荐
- 2.9 overview of databinding knowledge points
- PHP导出word方法(一phpword)
- Laravel time zone timezone
- Shardingsphere sub database and sub table < 3 >
- (構造筆記)從類、API、框架三個層面學習如何設計可複用軟件實體的具體技術
- Dart: About zone
- Redis notes 01: Introduction
- previous permutation lintcode51
- Lambda表达式
- Talk about the state management mechanism in Flink framework
猜你喜欢
vulnhub之Nagini
During FTP login, the error "530 login incorrect.login failed" is reported
Prompt unread messages and quantity before opening chat group
Itext7 uses iexternalsignature container for signature and signature verification
OPenGL 基本知识(根据自己理解整理)
[learning notes] DP status and transfer
[official MySQL document] deadlock
PHP导出word方法(一phpword)
Qt+vtk+occt reading iges/step model
【mysql专项】读锁和写锁
随机推荐
Unicode查询的官方网站
网络通讯之Socket-Tcp(一)
shardingSphere分库分表<3>
使用BLoC 构建 Flutter的页面实例
Vulnhub pyexp
typeScript
Adult adult adult
repo Manifest Format
Colleagues wrote a responsibility chain model, with countless bugs
Is BigDecimal safe to calculate the amount? Look at these five pits~~
Wechat applet - basic content
New features of ES6
2.6 preliminary cognition of synergetic couroutines
2.8 overview of ViewModel knowledge
Display time with message interval of more than 1 minute in wechat applet discussion area
Develop plug-ins for idea
4000字超详解指针
PHP export word method (phpword)
Introduction to concurrent programming (II)
(構造筆記)從類、API、框架三個層面學習如何設計可複用軟件實體的具體技術