Inetermediate VS Terminal Operations JAVA 8 Streams

Pubblicato il: 17 gennaio 2023
sul canale di: Interview Palace
54
8

About this Video:
Hello Friends, In this video we will talk and learn one of the very
important interview question and question is that What Is the Difference Between Intermediate and Terminal Operations in Java 8 Stream API ?


What is an Intermediate operation

The operations which return another stream as a result are called intermediate operations. V imp part, they are lazy.
Eg:

filter(), map(), distinct(), sorted(), limit(), skip()

What is Terminal operation
The operations which return non-stream values like primitive or object or collection or return nothing are called terminal operations

You can chain multiple intermediate operations and none of them will do anything until you invoke a terminal operation. At that time, all of the intermediate operations that you invoked earlier will be invoked along with the terminal operation.

Eg:

forEach(), toArray(), reduce(), collect(), min(), max(), count(), anyMatch(), allMatch(), noneMatch(), findFirst(), findAny()

Intermediate Operations

They return stream.
They can be chained together to form a pipeline of operations.
Pipeline of operations may contain any number of intermediate operations.
Intermediate operations are lazily loaded.
They don’t produce end result.


Terminal Operations

They return non-stream values.
They can’t be chained together.
Pipeline of operations can have maximum one terminal operation, that too at the end.
Terminal operations are eagerly loaded.
They produce end result.


In questa pagina del sito puoi guardare il video online Inetermediate VS Terminal Operations JAVA 8 Streams della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Interview Palace 17 gennaio 2023, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 54 volte e gli è piaciuto 8 spettatori. Buona visione!