Learn more about Kotlin, a new programming language designed to solve problems that software developers face every day brought to you in partnership with JetBrains.
In object-oriented programming, the iterator pattern is a design pattern in which an iterator is used to traverse a container and access the container's elements. The iterator pattern decouples algorithms from containers; in some cases, algorithms are necessarily container-specific and thus cannot be decoupled.
More about this pattern.
It is really hard to think about any other pattern that has been more successful. In particular, patterns have long been about overcoming shortcoming of the language or platform.
In this case, iterators has became part of both language and platform in most modern systems.
- Python’s __iter__()
Basically, it is so good, it is everywhere.
The Java Zone is brought to you in partnership with JetBrains. Discover how powerful static code analysis and ergonomic design make development not only productive but also an enjoyable experience.
Published at DZone with permission of
, DZone MVB
Opinions expressed by DZone contributors are their own.