当前位置:网站首页>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 .
边栏推荐
猜你喜欢
随机推荐
Talk about the state management mechanism in Flink framework
Laravel time zone timezone
previous permutation lintcode51
145. Post order traversal of binary tree
(database authorization - redis) summary of unauthorized access vulnerabilities in redis
Swagger
Dart: about Libraries
[combinatorics] permutation and combination (summary of permutation and combination content | selection problem | set permutation | set combination)
Download address and installation tutorial of vs2015
Atomic atomic operation
New features of ES6
OpenGL 着色器使用
wpa_ cli
Redis notes 01: Introduction
Solutions to the failure of installing electron
232. Implement queue with stack
AOSP ~ NTP (Network Time Protocol)
(构造笔记)从类、API、框架三个层面学习如何设计可复用软件实体的具体技术
Shutter: about inheritedwidget
(数据库提权——Redis)Redis未授权访问漏洞总结









