What is the Difference Between Fail-fast and Fail-safe Iterator in Java ?

Differences between Fail-fast and Fail-safe iterators are as follows...

Fail-fast iterator throws ConcurrentModificationException. But Fail-safe iterator does not throw this exception.

Fail-fast iterator does not clone the original collection. Fail-safe iterator creates a copy of the original collection of objects.

A Fail-fast iterator tries to immediately throw Exception when it encounters failure. A Fail-safe Iterator works on a copy of collection instead of original collection.



You May Interest

Why Collection Interface Doesn’t Extend Cloneable and Serializabl ...

What is the Difference Between wait and sleep Methods in Java ?

How remove Method is Implemented in a HashMap in Java ?

What are the Disadvantages of Multithreading in Java ?

When is UnsupportedOperationException Thrown in Java ?