Java中list循环删除元素
2021-01-26 22:14
阅读:485
标签:循环 col next code while iter 注意 使用 class
Iteratorit = list.iterator(); while(it.hasNext()){ String x = it.next(); if(x.equals("del")){ it.remove(); } }
注意:1、用for循环和增强for循环可能会导致list中含del的元素不能删完。
2、使用iterator的remove方法。
Java中list循环删除元素
标签:循环 col next code while iter 注意 使用 class
原文地址:https://www.cnblogs.com/fightmylife/p/12850903.html
上一篇:Python Casting
评论
亲,登录后才可以留言!