Please enable JavaScript to use CodeHS

AP CSA: VAR-2.E.4

CodeHS Lessons

Changing the size of an ArrayList while traversing it using an enhanced for loop can result in a ConcurrentModifcationException being thrown. Therefore, when using an enhanced for loop to traverse an ArrayList, you should not add or remove elements.

14.3 Traversing ArrayLists
7.3 Traversing ArrayLists
7.4 Enhanced For Loops
5.4 Enhanced For Loops