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
My top 10 tweets of the year
A thread 👇
https://t.co/xj4js6shhy
https://t.co/b81zoW6u1d
https://t.co/1147it02zs
https://t.co/A7XCU5fC2m
A thread 👇
https://t.co/xj4js6shhy
Entrepreneur\u2019s mind.
— James Clear (@JamesClear) August 22, 2020
Athlete\u2019s body.
Artist\u2019s soul.
https://t.co/b81zoW6u1d
When you choose who to follow on Twitter, you are choosing your future thoughts.
— James Clear (@JamesClear) October 3, 2020
https://t.co/1147it02zs
Working on a problem reduces the fear of it.
— James Clear (@JamesClear) August 30, 2020
It\u2019s hard to fear a problem when you are making progress on it\u2014even if progress is imperfect and slow.
Action relieves anxiety.
https://t.co/A7XCU5fC2m
We often avoid taking action because we think "I need to learn more," but the best way to learn is often by taking action.
— James Clear (@JamesClear) September 23, 2020
**Thread on Bravery of Sikhs**
(I am forced to do this due to continuous hounding of Sikh Extremists since yesterday)
Rani Jindan Kaur, wife of Maharaja Ranjit Singh had illegitimate relations with Lal Singh (PM of Ranjit Singh). Along with Lal Singh, she attacked Jammu, burnt - https://t.co/EfjAq59AyI
Hindu villages of Jasrota, caused rebellion in Jammu, attacked Kishtwar.
Ancestors of Raja Ranjit Singh, The Sansi Tribe used to give daughters as concubines to Jahangir.
The Ludhiana Political Agency (Later NW Fronties Prov) was formed by less than 4000 British soldiers who advanced from Delhi and reached Ludhiana, receiving submissions of all sikh chiefs along the way. The submission of the troops of Raja of Lahore (Ranjit Singh) at Ambala.
Dabistan a contemporary book on Sikh History tells us that Guru Hargobind broke Naina devi Idol Same source describes Guru Hargobind serving a eunuch
YarKhan. (ref was proudly shared by a sikh on twitter)
Gobind Singh followed Bahadur Shah to Deccan to fight for him.
In Zafarnama, Guru Gobind Singh states that the reason he was in conflict with the Hill Rajas was that while they were worshiping idols, while he was an idol-breaker.
And idiot Hindus place him along Maharana, Prithviraj and Shivaji as saviours of Dharma.
(I am forced to do this due to continuous hounding of Sikh Extremists since yesterday)
Rani Jindan Kaur, wife of Maharaja Ranjit Singh had illegitimate relations with Lal Singh (PM of Ranjit Singh). Along with Lal Singh, she attacked Jammu, burnt - https://t.co/EfjAq59AyI

Tomorrow again same thing happens bcoz fudus like you are creating a narrative oh Khalistan. when farmers are asking MSP. (RSS ki tatti khane wale Kerni sena ke kutte).
— Ancient Economist (@_stock_tips) December 5, 2020
U kill sikhs in 1984 just politics. To BC low IQ fudu Saale entire history was politics.
Hindu villages of Jasrota, caused rebellion in Jammu, attacked Kishtwar.
Ancestors of Raja Ranjit Singh, The Sansi Tribe used to give daughters as concubines to Jahangir.

The Ludhiana Political Agency (Later NW Fronties Prov) was formed by less than 4000 British soldiers who advanced from Delhi and reached Ludhiana, receiving submissions of all sikh chiefs along the way. The submission of the troops of Raja of Lahore (Ranjit Singh) at Ambala.
Dabistan a contemporary book on Sikh History tells us that Guru Hargobind broke Naina devi Idol Same source describes Guru Hargobind serving a eunuch
YarKhan. (ref was proudly shared by a sikh on twitter)
Gobind Singh followed Bahadur Shah to Deccan to fight for him.

In Zafarnama, Guru Gobind Singh states that the reason he was in conflict with the Hill Rajas was that while they were worshiping idols, while he was an idol-breaker.
And idiot Hindus place him along Maharana, Prithviraj and Shivaji as saviours of Dharma.

fascinated by this man, mario cortellucci, and his outsized influence on ontario and GTA politics. cortellucci, who lives in vaughan and ran as a far-right candidate for the italian senate back in 2018 - is a major ford donor...
his name might sound familiar because the new cortellucci vaughan hospital at mackenzie health, the one doug ford has been touting lately as a covid-centric facility, is named after him and his family
but his name also pops up in a LOT of other ford projects. for instance - he controls the long term lease on big parts of toronto's portlands... where doug ford once proposed building an nfl stadium and monorail... https://t.co/weOMJ51bVF
cortellucci, who is a developer, also owns a large chunk of the greenbelt. doug ford's desire to develop the greenbelt has been
and late last year he rolled back the mandate of conservation authorities there, prompting the resignations of several members of the greenbelt advisory

his name might sound familiar because the new cortellucci vaughan hospital at mackenzie health, the one doug ford has been touting lately as a covid-centric facility, is named after him and his family
but his name also pops up in a LOT of other ford projects. for instance - he controls the long term lease on big parts of toronto's portlands... where doug ford once proposed building an nfl stadium and monorail... https://t.co/weOMJ51bVF

cortellucci, who is a developer, also owns a large chunk of the greenbelt. doug ford's desire to develop the greenbelt has been
and late last year he rolled back the mandate of conservation authorities there, prompting the resignations of several members of the greenbelt advisory