Java concurrent modification exception

后端 未结 4 957
南笙
南笙 2021-01-21 08:24

I have written following code which is resulting in concurrent modification exception. How can I prevent it ? The idea is to escape all values of the Map and reconstruct the obj

4条回答
  •  庸人自扰
    2021-01-21 09:04

    You should remove/add only if you are changing a key in a map. As I see in the code, you are changing only value. Hence you could use entry.setValue(...) instead.

提交回复
热议问题