当前位置:网站首页>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 .
边栏推荐
猜你喜欢
随机推荐
Socket TCP for network communication (I)
实现验证码验证
If you can't learn, you have to learn. Jetpack compose writes an im app (I)
Qt OpenGL相机的使用
Dart: view the dill compiled code file
(database authorization - redis) summary of unauthorized access vulnerabilities in redis
SLF4J 日志门面
Introduction to concurrent programming (I)
Shardingsphere sub database and sub table < 3 >
使用BLoC 构建 Flutter的页面实例
1-2 project technology selection and structure
php 获取文件夹下面的文件列表和文件夹列表
OPenGL 基本知识(根据自己理解整理)
vulnhub之Nagini
QT OpenGL rotate, pan, zoom
Unicode查询的官方网站
OpenGL shader use
previous permutation lintcode51
(数据库提权——Redis)Redis未授权访问漏洞总结
(construction notes) learn the specific technology of how to design reusable software entities from three levels: class, API and framework








![[learning notes] DP status and transfer](/img/5e/59c64d2fe08b89fba2d7e1e6de2761.png)
