InterviewSolution
| 1. |
What Is Fail Fast Iterator? |
|
Answer» An iterator is considered fail-fast if it throws a CONCURRENTMODIFICATIONEXCEPTION under either of the following two conditions:
fail-fast iterator will throw a ConcurrentModificationException if the underlying collection is structurally modified in any way except through the iterator's own remove or add (if applicable as in list-iterator) methods. Note that structural modification is any operation that adds or deletes one or more elements; merely SETTING the value of an element (in case of list) or changing the value associated with an existing key (in case of map) is not a structural modification. An iterator is considered fail-fast if it throws a ConcurrentModificationException under either of the following two conditions: fail-fast iterator will throw a ConcurrentModificationException if the underlying collection is structurally modified in any way except through the iterator's own remove or add (if applicable as in list-iterator) methods. Note that structural modification is any operation that adds or deletes one or more elements; merely setting the value of an element (in case of list) or changing the value associated with an existing key (in case of map) is not a structural modification. |
|