Skip to content

feat: add streams concept #2983

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions concepts/streams/.meta/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"blurb": "Java Streams provide a powerful way to process collections using a functional approach.",
"authors": ["Navaneedan"],
"contributors": []
}

25 changes: 25 additions & 0 deletions concepts/streams/about.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# About
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, the about.md follows the introduction.md, although it can also have more information. See the about.md documentation or the lists, datetime or randomness for examples.


Streams in Java offer a modern, functional approach to processing data. Instead of writing verbose loops, you can build pipelines that transform collections with clarity and elegance.

Streams are built on three key components:

1. **Source** – Typically a collection like a `List` or `Set`.
2. **Intermediate Operations** – Transformations such as `filter`, `map`, or `sorted`.
3. **Terminal Operation** – Produces a result, like `collect`, `count`, or `forEach`.

```java
List<String> names = List.of("Dharshini", "Naveen", "Selena");

List<String> filtered = names.stream()
.filter(name -> name.startsWith("N"))
.collect(Collectors.toList());

// => ["Naveen"]
```


[Java Stream API Overview]:https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html
[Collectors Class]:https://docs.oracle.com/javase/8/docs/api/java/util/stream/Collectors.html
[Java Functional Programming with Streams]:https://www.baeldung.com/java-8-streams
[Stream Operations Explained]:https://www.geeksforgeeks.org/stream-in-java/
13 changes: 13 additions & 0 deletions concepts/streams/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Introduction

Imagine you’re at an airport, watching suitcases glide past on a conveyor belt. You don’t grab every bag—you scan for yours, maybe sort by color or tag, and pick only what you need. That’s how Java Streams work.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the use of the analogy! Just one thing - each sentence should be on a new line (see our paragraph specification).

Suggested change
Imagine you’re at an airport, watching suitcases glide past on a conveyor belt. You don’t grab every bag—you scan for yours, maybe sort by color or tag, and pick only what you need. That’s how Java Streams work.
Imagine you’re at an airport, watching suitcases glide past on a conveyor belt.
You don’t grab every bag—you scan for yours, maybe sort by color or tag, and pick only what you need.
That’s how Java Streams work.


Instead of writing loops and mutating variables, you describe *what* you want to do with the data. Want to filter out expensive items? Map names to uppercase? Count how many entries match a condition? Streams make it all feel natural.

Streams are part of Java’s functional programming toolkit. They help you write code that’s:
- **Declarative** – Focused on intent, not mechanics.
- **Composable** – Easy to chain operations.
- **Lazy** – Efficient by computing only when needed.

Once you start using streams, you’ll find yourself writing fewer loops and more elegant pipelines. It’s not just cleaner—it’s fun.
Comment on lines +7 to +12
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should avoid promoting streams over for loops here. Generally, the introduction should focus on how to use streams (see introducton.md docs), not what they offer. I'd recommend having a look at existing concept introductions like lists, datetime or randomness.


18 changes: 18 additions & 0 deletions concepts/streams/links.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[
{
"url": "https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The track targets Java 21 and older, but these links are specifically for Java 8. Have there been any significant changes to this package since 8?

"description": "Java Stream API Overview"
},
{
"url": "https://docs.oracle.com/javase/8/docs/api/java/util/stream/Collectors.html",
"description": "Collectors Class"
},
{
"url": "https://www.baeldung.com/java-8-streams",
"description": "Java Functional Programming with Streams"
},
{
"url": "https://www.geeksforgeeks.org/stream-in-java/",
"description": "Stream Operations Explained"
}
]