The 30 second answer
The second call throws IllegalStateException saying the stream has already been operated upon or closed. Streams are single-use. Recreate the stream from the source, wrap creation in a Supplier, or collect once and reuse the result. If you need two results in one pass, use Collectors teeing.
Second call throws **IllegalStateException: stream has already been operated upon or closed**. Streams are single-use. Recreate from the source, or use a Supplier<Stream<T>>, or collect once and reuse the result (teeing if you need two results in one pass).
Sources:
Sources (0)
See inline citations in the answer above.