java list remove(i)
来源:互联网 发布:鹤山网络问政平台 编辑:程序博客网 时间:2024/06/16 10:55
使用
for(int i=0;i<list.size();i++){
list.remove(i);
}
这种办法会造成list.size()大小发生变化,导致不能完全循环,同事 i 变化之后会导致list也的顺序也变;
另外一种情况,如果通过integer的方式来删除list里面的数据也是行不通的,list.remove(i)只能是int, integer不能用,因为 list 里面integer是对象类型,int是数据类型,通过这种方式也不能删除;
所以:
Iterator<JSONBean> it=list.iterator();
while(it.hasNext()){
JSONBean json=it.next();
if(vu.equals(json.getVuID())){
it.remove();
}
}
这种方式才是正解。
阅读全文
0 0
- java list remove(i)
- JAVA list如何remove
- java list如何remove
- java list如何remove
- JAVA list如何remove
- Java list remove
- Remove Duplicates from Sorted List I
- Remove Duplicates from Sorted List I II
- Remove Duplicates from Sorted List I,II
- Remove Duplicates from Sorted List I II
- java list remove的问题
- Java:List的remove解析
- (java)Remove Linked List Elements
- java中list的remove
- Remove Element,Remove Duplicates frm Sorted Array I,II(List I,II),Valid Parentheses,ZigZag Conv
- 【LeetCode】Remove Duplicates from Sorted List I && II
- 【LeetCode】Remove Duplicates from Sorted List I && II
- [Leetcode] Remove Duplicates from Sorted List I | II
- springmvc使用注解方式设置定时器
- JDK动态代理Demo
- MySql检测阻塞,锁等待sql
- WLFUploadButton
- 《深入理解mybatis原理》 MyBatis的二级缓存的设计原理
- java list remove(i)
- Zookeeper-Zookeeper可以干什么
- Percona Server (IMPROVED BUFFER POOL SCALABILITY)
- 大数据导出到excel
- shiro cas 遇到 票根验证问题
- Python爬虫.修改请求头Header(学习笔记)
- 多进程多线程服务器(tcp_server)编写
- C++中switch字符串Cstring/string map中查找
- UESTC 1690 这是一道比CCCC简单题难的简单题