What is stream API, why is it needed?

 What is stream API, why is it needed?

Ans:-  stream is an interface from java.util.stream package which supports stream of objects,which means continuous flow of objects.


Stream<T> will perform the following operations:-

a. Intermediate operations
b.Terminal operations

=> The stream API is needed for several reasons:-

1.Functional programming Paradigm:-
The Stream API supports functional programming paradigm, allowing developers to express operations on data in a concise and expressive manner.

2.Parallelism:- The stream API supports parallel processing, making it easier to take advantage of multi-core processors .Parallel stream can be created to process elements concurrently.

3.Code Readability:- Using the Stream API often leads to more readable and maintainable code. 

4.Efficient Operations:- Stream operations, such as map, filter, and reduce, are designed to be efficient.


Comments

Popular posts from this blog

How to create React project using command prompt?

How to achieve abstraction?

Interview Question? How to find square of each element in this Array {2,4,5,6,8} using map ?