jargon

Comparison

InternalvsExternal iterator

Internal

Defined by the difference stated below.

External iterator

one version hands you each element and you decide when to stop; the other takes your function and runs the loop itself.

An external iterator gives the caller control — next, hasNext, break out whenever — while an internal one takes a function and drives the loop itself, as forEach and map do. External iteration composes with early exit, zipping two sequences and resuming; internal iteration is shorter and lets the collection choose the traversal, including running it in parallel. The distinction explains why some collection APIs make an ordinary break impossible.

Full entry →

The difference

An external iterator gives the caller control — next, hasNext, break out whenever — while an internal one takes a function and drives the loop itself, as forEach and map do. External iteration composes with early exit, zipping two sequences and resuming; internal iteration is shorter and lets the collection choose the traversal, including running it in parallel. The distinction explains why some collection APIs make an ordinary break impossible.

Entry: Internal vs external iterator

Related comparisons