Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add new Streams concept with intro and resources #3041

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
ZaildarAnmol wants to merge 1 commit into exercism:main
base: main
Choose a base branch
Loading
from ZaildarAnmol:add-streams-concept

Conversation

@ZaildarAnmol
Copy link

@ZaildarAnmol ZaildarAnmol commented Oct 31, 2025

pull request


Reviewer Resources:

Track Policies

Copy link
Member

@kahgoh kahgoh left a comment
edited
Loading

Choose a reason for hiding this comment

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

Thanks for wanting to contribute the Streams concept, but there is already an open PR for this (#2983) so I'm going to put this one on hold by putting this in "requested changes" state. Admittedly, the other one hasn't had activity for a while, so I've pinged the other PR's author on that one. If there's no reply or if they've lost interest, I'll come back to review this one.

Java Streams provide a functional, declarative approach to processing collections of data.

Instead of writing explicit loops, Streams let you build **pipelines** of operations — transforming data step-by-step in a clean, readable way.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would also introduce the intermediate and terminal methods to introduce the possiblity of chaining function.

  • I would also introduce the usage of the lambda with only one function to execute which makes more readable

List<String> names = List.of("Arjun", "Riya", "Sam", "Aman");

names.stream()
.filter(n -> n.startsWith("A"))
Copy link
Contributor

Choose a reason for hiding this comment

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

I would introduce, as an intermediate operation:

  • filter
  • map, mapToInt, mapToLong...
  • peek
  • limit
  • distinct
  • sorted
  • skip

And Termination operations:

  • collect
  • count
  • reduce
  • anyMatch
  • findFirst

Copy link
Member

Choose a reason for hiding this comment

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

I agree it would be good to introduce some of theses operations. Note we don't need a complete list, but having some would be great.

xinri reacted with thumbs up emoji
Copy link
Contributor

Choose a reason for hiding this comment

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

agree. I would think that at least the collect and findfirst or anyMatch should be introduced:

  • Collect is one of the terminal operation that is widely used.
  • a terminal operation liike findfirst to show we can return only one element and anyMatch to show that a stream can return a boolean

Copy link
Member

@kahgoh kahgoh left a comment

Choose a reason for hiding this comment

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

Thanks for wanting to contribute the Streams concept, but there is already an open PR for this (#2983) so I'm going to put this one on hold by putting this in "requested changes" state. Admittedly, the other one hasn't had activity for a while, so I've pinged the other PR's author on that one. If there's no reply or if they've lost interest, I'll come back to review this one.

Its been a few weeks without a response to the other PR, so I think we can continue with this one.

Comment on lines +9 to +13
### Creating Streams
Streams can be created from collections, arrays, or I/O channels:
```java
List<Integer> numbers = List.of(1, 2, 3, 4, 5);
Stream<Integer> stream = numbers.stream();
Copy link
Member

Choose a reason for hiding this comment

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

This content is incomplete

List<String> names = List.of("Arjun", "Riya", "Sam", "Aman");

names.stream()
.filter(n -> n.startsWith("A"))
Copy link
Member

Choose a reason for hiding this comment

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

I agree it would be good to introduce some of theses operations. Note we don't need a complete list, but having some would be great.

xinri reacted with thumbs up emoji

A **Stream** is a sequence of elements that supports operations like filtering, mapping, and reducing.
It allows you to transform and analyze collections without using traditional loops.

Copy link
Member

Choose a reason for hiding this comment

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

I think this is also missing how to get a Stream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@kahgoh kahgoh kahgoh requested changes

+1 more reviewer

@xinri xinri xinri left review comments

Reviewers whose approvals may not affect merge requirements

Requested changes must be addressed to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /