terminal stream operation in Java
<b>Terminal stream operations</b> Method | What Happens for Infinite Streams | Return Value | Reduction ----- | ----- | ----- | ----- allMatch()<br>/anyMatch()<br>/noneMatch() | Sometimes terminates | boolean | No collect() | Does not terminate | Varies | Yes count() | Does not terminate | long | Yes findAny()<br>/findFirst() | Terminates | Optional<T> | No forEach() | Does not terminate | void | No min()/max() | Does not terminate | Optional<T> | Yes reduce() | Does not terminate | Varies | Yes