首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

java list的准确remove。避免报java.util.ConcurrentModificationException

2012-09-03 
java list的正确remove。避免报java.util.ConcurrentModificationExceptionlist的remove首先要从迭代器中re

java list的正确remove。避免报java.util.ConcurrentModificationException
list的remove首先要从迭代器中remove
list的正确的remove的办法:

Iterator<StoreFriendLink >  it=friendlinks.iterator();
                   while(it.hasNext()){
                        StoreFriendLink next=it.next();
                         if(next.getId().equals(id)){
                              it.remove();
                              friendlinks.remove(next);
                        }
                  }

热点排行