Edited for Clarity
I was following a set of tutorial videos on design patterns that use Java to demonstrate various pattern uses, but when I got to the video titled "The Iterator Design Pattern" it just seemed to use a standard Java iterator. I have used iterators in Java before, but was never taught them as a "design pattern." Is there a difference between using an iterator in Java and using the "iterator design pattern"? If so, what is the distinction?
The iterators you have used in Java actually implement the Iterator design pattern. They do:
Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation. -Wikipedia Article definition-
As you can see in the documentation of the Iterable interface in Java, most of the containers you know supply an Iterator object used to:
access their elements sequentially without exposing their underlying representation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With