Say I have a list on which I need to perform operations. If I chain those operations with streaming API, is it necessary to call a terminal operation or just stopping at intermediate operations can also be fine?
list.stream().filter(some filtering).peek(some change on the filtered items);
list.stream().filter(some filtering).peek(some change on the filtered items).close();
Changing this to
list.stream().filter(some filtering).forEach(some change on the filtered items)
does what I want.
Is there any possibility of memory leaks in the first option ? Why the peek() version doesn't work ??
Is close() a terminal operation and if it is, will this help me call setter on the filtered list items.
This question is