`

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);
                        }
                  }
0
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics