Iterator Design Pattern In Java

Iterator Design Pattern In Java

Today, I will discuss a relatively simple and very commonly used behavioral design pattern called — Iterator Design Pattern. Iterator Pattern provides a simple way to iterate through the collection of objects.

Today, I will discuss a relatively simple and very commonly used behavioral design pattern called — Iterator Design Pattern. Iterator Pattern provides a simple way to iterate through the collection of objects.

Iterator Design Pattern

  • The Iterator Design Pattern is one of twenty-three well known GoF design patterns provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation. 
  • Iterator Design Pattern provides an Iterator object to traverse a collection/container and access its member objects.
  • Iterator Design Pattern is a relatively simple design pattern, which we use almost in every project.
  • Few container requires an algorithm to access the member elements. Iterator Design Patterndecouples any such algorithm from the container.
  • The algorithm can be written separately to use by the Iterator and hence can be use by any container which supports that kind of Iterator object.
  • The Iterator Design Pattern provides flexible and reusable solution of traversing member objects of a container/collection. That make our collection object easier to implement, change, test and reuse.
  • *Iterator *object also facilitate removing of member object while traversing the collection. So, it's one of the solution of ConcurrentModificationException.

iterator design pattern

Here, the aggregate is nothing but the container/collection which offers Iterator to traverse itself.

java design pattern

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Proxy Design Pattern in JAVA

In this blog, we will discuss Proxy Design Pattern, its example, and how it is different from the other design patterns. But, it’s important to have an understanding of the design patterns first. You can refer here.

Java Design Patterns for Beginners - Design Patterns in Java

"Java Design Patterns for Beginners - Design Patterns in Java - Design Patterns Tutorial" will provide you with detailed knowledge about Java Design Patterns and along with it. Why do we need Design Patterns? Structure of Design Patterns. Types of Design Patterns. Creational Design Patterns. Factory Design Pattern. Overview of Design Patterns

How to Install OpenJDK 11 on CentOS 8

What is OpenJDK? OpenJDk or Open Java Development Kit is a free, open-source framework of the Java Platform, Standard Edition (or Java SE).

Composite Design Pattern in Java

This post looks at how to use the composite design pattern in Java, specifically the objects used in the pattern: component, composite, leaf, and client.

Memento Design Pattern In Java

Today, I would like to discuss another behavioral design pattern called the Memento Design Pattern which is used to restore the state of an object to a previous state.