Client Code (Main Program):?
- The client code creates a ProductCollection and uses the iterator to
sequentially access each product in the collection. It doesn’t need to know the
internal structure of the collection (whether it’s a list, array, or any other data
structure).
Benefits of the Iterator Pattern: