当前位置:网站首页>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 .
边栏推荐
猜你喜欢

CGroup introduction

AOSP ~ NTP (Network Time Protocol)

Qt+vtk+occt reading iges/step model

C language improvement article (wchar_t) character type
![[learning notes] DP status and transfer](/img/5e/59c64d2fe08b89fba2d7e1e6de2761.png)
[learning notes] DP status and transfer

Wechat applet - basic content

PHP導出word方法(一mht)

使用BLoC 构建 Flutter的页面实例

If you can't learn, you have to learn. Jetpack compose writes an im app (I)

PHP export word method (one MHT)
随机推荐
4000字超详解指针
Introduction to concurrent programming (II)
Prompt unread messages and quantity before opening chat group
(construction notes) learn the specific technology of how to design reusable software entities from three levels: class, API and framework
(构造笔记)GRASP学习心得
MySQL time zone solution
Qt+vtk+occt reading iges/step model
Adult adult adult
安装electron失败的解决办法
Basic knowledge of OpenGL (sort it out according to your own understanding)
DEJA_ Vu3d - 054 of cesium feature set - simulate the whole process of rocket launch
使用BLoC 构建 Flutter的页面实例
repo Manifest Format
Unicode encoding table download
Shardingsphere sub database and sub table < 3 >
242. Effective letter heteronyms
【附下载】密码获取工具LaZagne安装及使用
Socket TCP for network communication (I)
Socket TCP for network communication (I)
Download address and installation tutorial of vs2015