From 83cb9a53f90d9406bb229f7f082f462440cb86d8 Mon Sep 17 00:00:00 2001 From: Anmol Singh Date: Fri, 31 Oct 2025 03:07:07 -0400 Subject: [PATCH] Add new Streams concept with intro and resources --- concepts/streams/about.md | 13 +++++++++++++ concepts/streams/config.json | 6 ++++++ concepts/streams/introduction.md | 22 ++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 concepts/streams/about.md create mode 100644 concepts/streams/config.json create mode 100644 concepts/streams/introduction.md diff --git a/concepts/streams/about.md b/concepts/streams/about.md new file mode 100644 index 000000000..c666d7276 --- /dev/null +++ b/concepts/streams/about.md @@ -0,0 +1,13 @@ +# About Streams + +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. + +--- + +### Creating Streams +Streams can be created from collections, arrays, or I/O channels: +```java +List numbers = List.of(1, 2, 3, 4, 5); +Stream stream = numbers.stream(); diff --git a/concepts/streams/config.json b/concepts/streams/config.json new file mode 100644 index 000000000..d44820a93 --- /dev/null +++ b/concepts/streams/config.json @@ -0,0 +1,6 @@ +{ + "blurb": "Learn how to use Java Streams for functional and declarative data processing.", + "authors": ["Zaildar_Anmol"], + "contributors": [], + "forked_from": null +} diff --git a/concepts/streams/introduction.md b/concepts/streams/introduction.md new file mode 100644 index 000000000..41ead8882 --- /dev/null +++ b/concepts/streams/introduction.md @@ -0,0 +1,22 @@ +# Introduction + +The `Stream` API, introduced in Java 8, provides a modern, functional way to process data. + +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. + +Example: +```java +import java.util.*; +import java.util.stream.*; + +public class Example { + public static void main(String[] args) { + List names = List.of("Arjun", "Riya", "Sam", "Aman"); + + names.stream() + .filter(n -> n.startsWith("A")) + .map(String::toUpperCase) + .forEach(System.out::println); + } +}