Use when Java Streams API for functional-style data processing. Use when processing collections with streams.
View on GitHubTheBushidoCollective/han
jutsu-java
January 24, 2026
Select agents to install to:
npx add-skill https://github.com/TheBushidoCollective/han/blob/main/jutsu/jutsu-java/skills/java-streams-api/SKILL.md -a claude-code --skill java-streams-apiInstallation paths:
.claude/skills/java-streams-api/# Java Streams API
Master Java's Streams API for functional-style operations on collections,
enabling declarative data processing with operations like filter, map, and
reduce.
## Introduction to Streams
Streams provide a functional approach to processing collections of objects.
Unlike collections, streams don't store elements - they convey elements from
a source through a pipeline of operations.
**Creating streams:**
```java
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;
public class StreamCreation {
public static void main(String[] args) {
// From collection
List<String> list = Arrays.asList("a", "b", "c");
Stream<String> stream1 = list.stream();
// From array
String[] array = {"a", "b", "c"};
Stream<String> stream2 = Arrays.stream(array);
// Using Stream.of()
Stream<String> stream3 = Stream.of("a", "b", "c");
// Empty stream
Stream<String> stream4 = Stream.empty();
// Infinite stream with limit
Stream<Integer> stream5 = Stream.iterate(0, n -> n + 1)
.limit(10);
}
}
```
## Intermediate Operations
Intermediate operations return a new stream and are lazy - they don't
execute until a terminal operation is invoked.
**filter() - Select elements:**
```java
import java.util.List;
import java.util.stream.Collectors;
public class FilterExample {
public static void main(String[] args) {
List<Integer> numbers = List.of(1, 2, 3, 4, 5, 6, 7, 8);
// Filter even numbers
List<Integer> evenNumbers = numbers.stream()
.filter(n -> n % 2 == 0)
.collect(Collectors.toList());
// Result: [2, 4, 6, 8]
// Multiple filters can be chained
List<Integer> result = numbers.stream()
.filter(n -> n > 3)
.filter(n -> n < 7)
.collect(Collectors.toList());
// Result: [4, 5, 6]
}
}
```
**m