Sometimes I want to perform a set of operations on a stream, and then process the resulting stream two different ways with other operations.
Can I do this without ha
Either,
This has the advantage of being explicit about what you are doing, and also works for infinite streams.
In your example:
final int[] arr = IntStream.range(1, 100).filter(n -> n % 2 == 0).toArray();
Then
final IntStream s = IntStream.of(arr);