Pola Iterator nyedhiyakake cara kanggo melintasi koleksi sacara urut tanpa mbukak struktur internal. Iki dadi pola sing dhasar banget nganti dibangun ing umume basa modern (for-of loops, iterators, generators).
Apa sing ditindakake pola Iterator
ITERATOR → access elements of a collection SEQUENTIALLY without exposing its internals:
→ provides a standard way to traverse (next element, has more?)
→ the collection's internal structure (array, tree, linked list) is HIDDEN
→ decouples traversal logic from the collection
→ "iterate without caring how the collection is structured"
