Skip to main content

Difference between intermediate and terminal operations in Streams.

Entry Java
Quick Answer Intermediate operations are lazy - they don't execute until a terminal op is called and return a Stream. Examples: filter(), map(), flatMap(), sorted(), distinct(), limit(), peek(). Terminal operations trigger execution and produce a result or side effect. Examples: collect(), count(), forEach(), reduce(), findFirst(), anyMatch(), toList(). Only one terminal operation per stream pipeline.

Answer

Intermediate operations are lazy and return streams (map, filter, sorted).
Terminal operations produce results (collect, forEach, reduce).
Pipeline allows chaining multiple intermediate operations.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice