码迷,mamicode.com
首页 > 编程语言 > 详细

Caused by: java.util.ConcurrentModificationException

时间:2016-04-22 16:20:13      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:

for循环迭代数据是,不能进行add remove操作,可以先记录下需要操作的下标,然后循环下标数组进行操作。

 

List<Integer>index=new ArrayList<>();
for(int i=0;i<list.size();i++){
for(Events.PlayerItemEvent item:TeamDataList.mcList){
if(item!=null&&item.getPlayerId().equals(list.get(i).getPlayerId())){
index.add(i);
}
}
}
for(Integer a:index){
list.remove(a);
}

Caused by: java.util.ConcurrentModificationException

标签:

原文地址:http://www.cnblogs.com/yulook/p/5421548.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!