java-streams-api
БесплатноБез исполняемых скриптовНе проверенUse when Java Streams API for functional-style data processing. Use when processing collections with streams.
от TheBushidoCollective★ 202 звезды на GitHubОб этом скилле
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:
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:
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]
}
}
map() - Transform elements:
public class MapExample {
public static void main(String[] args) {
List<String> words = List.of("hello", "world");
// Convert to uppercase
List<String> uppercase = words.stream()
.map(String::toUpperCase)
.collect(Collectors.toList());
// Result: ["HELLO", "WORLD"]
// Get string lengths
List<Integer> lengths = words.stream()
.map(String::length)
.collect(Collectors.toList());
// Result: [5, 5]
// Chain transformations
List<Integer> doubled = List.of(1, 2, 3).stream()
.map(n -> n * 2)
.collect(Collectors.toList());
// Result: [2, 4, 6]
}
}
flatMap() - Flatten nested structures:
public class FlatMapExample {
public static void main(String[] args) {
List<List<Integer>> nested = List.of(
List.of(1, 2),
List.of(3, 4),
List.of(5, 6)
);
// Flatten to single list
List<Integer> flattened = nested.stream()
.flatMap(List::stream)
.collect(Collectors.toList());
// Result: [1, 2, 3, 4, 5, 6]
// Split strings and flatten
List<String> sentences = List.of("hello world", "foo bar");
List<String> words = sentences.stream()
.flatMap(s -> Arrays.stream(s.split(" ")))
.collect(Collectors.toList());
// Result: ["hello", "world", "foo", "bar"]
}
}
distinct() and sorted():
public class DistinctSortedExample {
public static void main(String[] args) {
List<Integer> numbers = List.of(5, 2, 8, 2, 1, 5, 3);
// Remove duplicates
List<Integer> distinct = numbers.stream()
.distinct()
.collect(Collectors.toList());
// Result: [5, 2, 8, 1, 3]
// Sort ascending
List<Integer> sorted = numbers.stream()
.sorted()
.collect(Collectors.toList());
// Result: [1, 2, 2, 3, 5, 5, 8]
// Sort descending
List<Integer> descending = numbers.stream()
.sorted((a, b) -> b - a)
.collect(Collectors.toList());
// Distinct and sorted
List<Integer> distinctSorted = numbers.stream()
.distinct()
.sorted()
.collect(Collectors.toList());
// Result: [1, 2, 3, 5, 8]
}
}
peek() - Debug or perform side effects:
public class PeekExample {
public static void main(String[] args) {
List<Integer> numbers = List.of(1, 2, 3, 4, 5);
// Debug stream pipeline
List<Integer> result = numbers.stream()
.peek(n -> System.out.println("Original: " + n))
.map(n -> n * 2)
.peek(n -> System.out.println("Doubled: " + n))
.filter(n -> n > 5)
.peek(n -> System.out.println("Filtered: " + n))
.collect(Collectors
Установить java-streams-api в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
BashReadWriteEditFAQ
Что делает скилл java-streams-api?
Use when Java Streams API for functional-style data processing. Use when processing collections with streams.
Как установить скилл java-streams-api?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл java-streams-api запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic