TryBugHunt

Java collection exercises

Java collections are central to enterprise software, but common mistakes lead to silent bugs or runtime crashes: mutating an ArrayList while iterating over it, storing objects in a HashSet without overriding hashCode(), or modifying List.of() immutable lists.

Debug real Java collection pipelines and master the Java Collections Framework.

See the 17 exercisesOr follow the 30-day path

The collections bugs you will meet

The exercises

Errors you might be searching for

More JavaScript practice by topic

Questions

How do I safely remove elements while looping in Java?

Use Collection.removeIf(predicate) in modern Java, or obtain an explicit Iterator and call iterator.remove().