Stream never modifies the source data, it processes it and gives us the result without modifying the original data.
Java: Beginner Guide to Stream API
a thread...
Stream never modifies the source data, it processes it and gives us the result without modifying the original data.
1. Collection. stream()
2. Stream.of(T... values)
3. Arrays. stream()
4. Stream.builder()
Eg:️
1. Intermediate Operations(IO)
2. Terminal Operations(TO)
Here's what the stream pipeline looks like:
Source -> Intermediate Operations -> Terminal Operations
It returns another stream object, after this, we can either call another IO or TO.
Few methods in Stream API for Intermediate operations:
1. filter()
2. map()
3. sorted()
and many more...
filter() - filters out the data based on any boolean condition - below we're filtering elements starting with the letter a.
map() - performs some given operation on the whole data set - below we're converting every element to upper case.
It's the last operation done on stream that's why it's called terminal.
This operation returns the final result.
Few methods in Stream API for Terminal operations:
1. collect()
2. count()
3. forEach()
and many more...
collect() - collects the elements in the given collection as shown below in the first case it is returning data in the form of a list.
count() - counts the no of the element in the stream and returns in the form of long.
More from Vikas Rajput
Learn Core Java, in 30 days as an Absolute Beginner
a roadmap...
Core Java can be Overwhelming, in the beginning!
Let's see what are those topics you should cover and what you can skip in Core Java.
1. Theoretical Concepts (2 days)
- Features of Java
- JVM, JRE & JDK
- Memory areas in Java
- Basics of how Garbage Collection Works.
2. OOP Concepts (3 days)
- Objects and Classes
- Inheritance
- Polymorphism
- Encapsulation
This topic forms the basis of your Java learning. Spent enough time on this topic and understanding it using real-world examples and some
3. Primitives data types, Operators & Arrays (3 days)
- Various primitives/non-primitives data types, operators
- What is their use, How to use them
- Various sizes of data types
- Arrays, practice a few of its problems
- 2D/3D arrays and their use cases, practice a few problems
a roadmap...
Core Java can be Overwhelming, in the beginning!
Let's see what are those topics you should cover and what you can skip in Core Java.
1. Theoretical Concepts (2 days)
- Features of Java
- JVM, JRE & JDK
- Memory areas in Java
- Basics of how Garbage Collection Works.
2. OOP Concepts (3 days)
- Objects and Classes
- Inheritance
- Polymorphism
- Encapsulation
This topic forms the basis of your Java learning. Spent enough time on this topic and understanding it using real-world examples and some
OOPs Concept in Java
— Vikas Rajput (@vikasrajputin) April 4, 2022
a thread...
3. Primitives data types, Operators & Arrays (3 days)
- Various primitives/non-primitives data types, operators
- What is their use, How to use them
- Various sizes of data types
- Arrays, practice a few of its problems
- 2D/3D arrays and their use cases, practice a few problems
You May Also Like
"I lied about my basic beliefs in order to keep a prestigious job. Now that it will be zero-cost to me, I have a few things to say."
We know that elite institutions like the one Flier was in (partial) charge of rely on irrelevant status markers like private school education, whiteness, legacy, and ability to charm an old white guy at an interview.
Harvard's discriminatory policies are becoming increasingly well known, across the political spectrum (see, e.g., the recent lawsuit on discrimination against East Asian applications.)
It's refreshing to hear a senior administrator admits to personally opposing policies that attempt to remedy these basic flaws. These are flaws that harm his institution's ability to do cutting-edge research and to serve the public.
Harvard is being eclipsed by institutions that have different ideas about how to run a 21st Century institution. Stanford, for one; the UC system; the "public Ivys".
As a dean of a major academic institution, I could not have said this. But I will now. Requiring such statements in applications for appointments and promotions is an affront to academic freedom, and diminishes the true value of diversity, equity of inclusion by trivializing it. https://t.co/NfcI5VLODi
— Jeffrey Flier (@jflier) November 10, 2018
We know that elite institutions like the one Flier was in (partial) charge of rely on irrelevant status markers like private school education, whiteness, legacy, and ability to charm an old white guy at an interview.
Harvard's discriminatory policies are becoming increasingly well known, across the political spectrum (see, e.g., the recent lawsuit on discrimination against East Asian applications.)
It's refreshing to hear a senior administrator admits to personally opposing policies that attempt to remedy these basic flaws. These are flaws that harm his institution's ability to do cutting-edge research and to serve the public.
Harvard is being eclipsed by institutions that have different ideas about how to run a 21st Century institution. Stanford, for one; the UC system; the "public Ivys".