The Javadoc states that
This is a short-circuiting stateful intermediate operation.
Definition of stateful from Javadoc:
Stateful operations, such as distinct and sorted, may incorporate state from previously seen elements when processing new elements. Stateful operations may need to process the entire input before producing a result. For example, one cannot produce any results from sorting a stream until one has seen all elements of the stream. As a result, under parallel computation, some pipelines containing stateful intermediate operations may require multiple passes on the data or may need to buffer significant data. Pipelines containing exclusively stateless intermediate operations can be processed in a single pass, whether sequential or parallel, with minimal data buffering.
How is default Stream<T> takeWhile(Predicate<? super T> predicate) stateful?It does not need look at the entire input, etc...
It's almost like filter but short-circuiting.