remove elements from CopyOnWriteArrayList

前端 未结 9 1980
醉酒成梦
醉酒成梦 2020-12-29 09:27

I am getting an exception when I try to remove elements from CopyOnWriteArrayList using an iterator. I have noticed that it is documented

Element-c

9条回答
  •  北海茫月
    2020-12-29 09:54

    Iterate over the collection choosing all the elements you want to delete and putting those in a temporary collection. After you finish iteration remove all found elements from the original collection using method removeAll.

    Would that work out for you? I mean, not sure if deletion logic is more complicated than that in your algorithm.

提交回复
热议问题