Explain the difference between intermediate and terminal operations in java8?



Explain the difference between intermediate and terminal operations in java8?..

Answer / Shiv Shankar

Intermediate Operations are lazy in Java 8 Stream API, meaning they produce a new stream without consuming any elements from the source stream. They can be further chained with other operations to form complex pipelines. Terminal Operations are greedy; they consume all elements of the stream and return a result or no result (void). Examples of intermediate operations include filter(), map(), limit(), distinct(); while examples of terminal operations include count(), forEach(), reduce(), collect().

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

What classes of exceptions may be thrown by a throw statement?

1 Answers  


What is private public protected in java?

1 Answers  


What data structures are used to perform recursion?

1 Answers   Akamai Technologies,


What is predicate in java?

1 Answers  


can java object be locked down for exclusive use by a given thread? Or what happens when a thread cannot acquire a lock on an object? : Java thread

1 Answers  


What is the name of the java compiler?

1 Answers  


What are parent methods and how can you call them?

2 Answers  


What are the new features in java 8?

1 Answers  


Explain illegalmonitorstateexception and when it will be thrown?

1 Answers  


What are alternatives to java serialization?

1 Answers  


Is null keyword in java?

1 Answers  


What is a pattern what is an anti pattern?

1 Answers  


Categories