当前位置:网站首页>Collection delete element technique removeif
Collection delete element technique removeif
2022-06-10 23:56:00 【Li_ XiaoJin】
removeIf
removeIf() It's from JDK1.8 Start offering .
see API file :
Delete all elements of this collection that satisfy the given predicate . Errors or runtime exceptions thrown in iterations or predicates are forwarded to the caller .
We deleted List Elements in , Generally, loop traversal is used to realize . Found today removeIf useful , Make a note of .
Previous practice :
List<String> testList = new ArrayList<>();
Iterator<String> it = testList.iterator();
while (it.hasNext()) {
if ("aa".equals(it.next())) {
it.remove();
}
}
Now you can use :
testList.removeIf(s -> "aa".equals(s));
// perhaps
testList.removeIf("aa"::equals);
Copyright: use Creative Commons signature 4.0 International license agreement to license Links:https://lixj.fun/archives/list Delete element technique removeif
边栏推荐
- 【Pygame小游戏】这款经典的炸弹人超能游戏上线,你爱了嘛?(附源码)
- LabVIEW确定控件在显示器坐标系中的位置
- 基于CenterOS7安装Redis及常见问题解决(带图讲解)
- LabVIEW get IMAQ get last event coordinates
- [paper sharing] pata: fuzzing with path aware Taint Analysis
- How to generate automatic references (simple drawings)
- Binary tree pruning
- Is it safe for CICC Fortune Securities to open an account? Is it reliable?
- Baidu quick collection SEO optimization keyword ranking optimization skills
- Is it safe for changtou school to open an account? Is it reliable?
猜你喜欢

Prefer "big and small weeks", only write 200 lines of code every day, and the monthly salary of 8k-17k people will rise again

B 树的简单认识

【Opencv实战】这个印章“神器”够牛,节省了时间提高了效率,厉害~(附完整源码)

LabVIEW用VISA Read函数来读取USB中断数据

Exception 0xc00000005 code occurred when LabVIEW called DLL

Easyrecovery15 simple and convenient data recovery tool

【Pygame小游戏】《坦克大战》,那些童年的游戏你还记得几个呢?

【Pygame小游戏】这款经典的炸弹人超能游戏上线,你爱了嘛?(附源码)

LabVIEW中NI MAX中缺少串口

【Pygame小游戏】别找了,休闲游戏专题来了丨泡泡龙小程序——休闲游戏研发推荐
随机推荐
[opencv practice] this seal "artifact" is awesome, saving time and improving efficiency. It is powerful ~ (complete source code attached)
【Pygame小游戏】Chrome上的小恐龙竟可以用代码玩儿了?它看起来很好玩儿的样子~
Fiddler filtering sessions
Kubernetes 基本介绍及核心组件
Unity 脚本无法显示C#源码的中文注释 或者VS创建的脚本没有C#源码的注释
Leetcode 501: mode in binary search tree
选择排序
LabVIEW phase locked loop (PLL)
LabVIEW获取IMAQ Get Last Event坐标
Four ways to add names to threads in the thread pool
【Turtle表白合集】“海底月是天上月,眼前人是心上人。”余生多喜乐,长平安~(附3款源码)
Redis installation and common problem solving based on centeros7 (explanation with pictures)
Fiddler configuration
自制APP连接OneNET---实现数据监控和下发控制(MQTT)
30 | how to reset the consumer group displacement?
An adaptive size / full screen display method for iframe frames
LabVIEW performs a serial loopback test
【Pygame小遊戲】別找了,休閑遊戲專題來了丨泡泡龍小程序——休閑遊戲研發推薦
[mathematics] [continuum mechanics] symmetry tensor, strain tensor and stress tensor in fluid mechanics
[untitled]