Sitemap
Javarevisited

A humble place to learn Java and Programming better.

Member-only story

What is the difference between fail-fast and fail-safe iterators?

--

100 Days — 100+ Interview Questions

Hey friend,
From today, we will learn 100+ Interview Questions in 100 Days with complete, detailed explanations from scratch, which will help us understand concepts better and help us crack interviews.

You can get the complete Interview Series here.

Question

What is the difference between fail-fast and fail-safe iterators?

Before going into Fail-fast and fail-safe iterators, let’s first discuss what an Iterator is and go deep into its types.

What is an Iterator?

  • Iterators are just objects that allow you to traverse over a collection of data.
  • The iterator has methods like hasNext(), remove() and next() to determine if there is another object in your collection and to get the next one.
  • hasNext() method is used to determine whether there are elements in the collection we are traversing.
  • next() method is used to get the next element in the iteration.
  • remove() method is used to remove an element from the collection.
@Test
public void…
Javarevisited
Javarevisited

Published in Javarevisited

A humble place to learn Java and Programming better.

Thirupathi Pavan Sai
Thirupathi Pavan Sai

Written by Thirupathi Pavan Sai

Software Engineer | 1X Azure certified | Backend | Cyber Security Enthusiast | DevOps Enthusiast

No responses yet