Skip to content

Conversation

@ZaildarAnmol
Copy link

pull request


Reviewer Resources:

Track Policies

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.

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.

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.


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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants