首页 > 编程语言 > 详细

Caused by: java.util.ConcurrentModificationException

时间:2016-04-22 16:18:30      阅读:295      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!