intermediatePremium

The for-each Remove Trap

Why removing in a loop throws

The for-each Remove Trap

Removing from an ArrayList through the list during its for-each can throw ConcurrentModificationException (fail-fast is best-effort) - remove via the iterator.

The narrated version of this skribble — tap play for the full-size video.

1:43

The for-each Remove Trap

Premium
🔒

Premium skribble

The preview above is intentionally blurred. Unlock the full-resolution skribble — and its deep-dive board — with TechSkribble.

Unlock this course Already purchased? Sign in
#java#gotchas#collections#iterator