Quantcast
Channel: Java Code Samples » Old stuff
Viewing all articles
Browse latest Browse all 10

Iterator

$
0
0

Description:

Is used to traverse a container and access the container’s elements. The iterator pattern decouples algorithms from containers.Containers may be a list , graph ,tree etc.

Benefits:

  • Supports variations in the traversal of a collection
  • Simplifies the interface of the collection

When to use:

  • Access collection object’s contents without exposing its internal representation
  • Support multiple traversals of objects in a collection
  •  Provide a uniform interface for traversing different structures in a collection

 

Diagram:

Code samples are below and can be downloaded here.




Viewing all articles
Browse latest Browse all 10

Trending Articles