what is the difference between intermediate and terminal operations?
When you invoke an intermediate operation on a stream, the operation is not executed immediately. It is executed only when a terminal operation is invoked on that stream. ... Terminal operations produces a non-stream (cannot be chained) result such as primitive value, a collection or no value at all.