当前位置:网站首页>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 .
边栏推荐
- Why can't my MySQL container start
- QT OpenGL texture map
- previous permutation lintcode51
- 1-1 token
- (construction notes) learn the specific technology of how to design reusable software entities from three levels: class, API and framework
- (构造笔记)ADT与OOP
- Optimize interface performance
- Use of atomicinteger
- 347. Top k high frequency elements
- 【mysql专项】读锁和写锁
猜你喜欢
随机推荐
MySQL time zone solution
Colleagues wrote a responsibility chain model, with countless bugs
1-2 project technology selection and structure
temp
Develop plug-ins for idea
Dart: About zone
Socket TCP for network communication (I)
网络通讯之Socket-Tcp(一)
Vulnhub's Nagini
Flutter: about monitoring on flutter applications
(構造筆記)從類、API、框架三個層面學習如何設計可複用軟件實體的具體技術
lambda与匿名内部类的区别
typeScript
111. Minimum depth of binary tree
laravel 时区问题timezone
Fundamentals of concurrent programming (III)
shardingSphere分库分表<3>
Optimize interface performance
OpenGL shader use
Swagger









