Why am I not getting a java.util.ConcurrentModificationException in this example?

后端 未结 10 2116
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-22 07:59

Note: I am aware of the Iterator#remove() method.

In the following code sample, I don\'t understand why the List.remove in main

10条回答
  •  悲哀的现实
    2020-11-22 08:39

    In my case I did it like this:

    int cursor = 0;
    do {
        if (integer.equals(remove))
            integerList.remove(cursor);
        else cursor++;
    } while (cursor != integerList.size());
    

提交回复
热议问题