Powered by Blogger.

Saturday 27 April 2024

How to Develop code logic using Stream API Workflow

2 comments :
Let's begin by defining the term stream as it applies to the stream API:
A stream operates on a data source, such as an array or a collection. A stream, itself, never provides storage on a data. It simply moves data, possibly filtering, sorting, or otherwise operating on that data is the process. as a genral rule, however a stream operation by itself does not modyfy the data source. For Example: sorting a stream does not change the order of the source. Rather, sorting a stream results in the creation of a new stream that produces the sroted result.
A Simple Stream Example : Let's work through an example that uses streams. The following program creates an ArrayList called myList that holds a collection of integers. Next, it obtains a stream that uses myList as a source.


OUTPUT: