Design patterns·Who calls whom, and when
one version hands you each element and you decide when to stop; the other takes your function and runs the loop itself.
Internal vs external iterator
Also calledinternal iterator, external iterator, push vs pull iteration
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.