Fundamentals

Default Methods

Collections

Idioms and Techniques

Design Rationale

Advanced Questions

How can I turn a Stream into an Iterable?

Stream has an iterator() method which will turn it into an Iterator. But sometimes you want an Iterable, not an Iterator, for example, to use the enhanced-for loop, or to pass to an existing API that requires an Iterable. Given a Stream s, the following results in an Iterable:

s::iterator

This is a bit counterintuitive. […]