Please enable JavaScript to use CodeHS


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