ConcurrentModificationException when using iterator and iterator.remove()

前端 未结 4 1939
旧时难觅i
旧时难觅i 2021-01-13 16:30
    private int checkLevel(String bigWord, Collection dict, MinMax minMax)
{
    /*value initialised to losing*/
    int value = 0; 
    if (minMax ==          


        
4条回答
  •  余生分开走
    2021-01-13 16:46

    Something somewhere is modifying dict. I suspect it might be happening inside this call:

    int value2 = checkLevel(removeWord(bigWord, str, i), dict, passin);
                                                         ^^^^
    

    edit Basically, what happens is that the recursive call to checkLevel() modifies dict through another iterator. This makes the outer iterator's fail-fast behaviour to kick in.

提交回复
热议问题