Stream Storm / Part 2YOUTUBE PLAYER LOADS ON PLAYreduce + groupingBy
reduce+groupingBy
Java reduce() and groupingBy() Explained Visually | Stream Storm Part 2
In this lesson
distinct drops repeats, limit stops early, reduce folds a list into one value, and groupingBy sorts items into buckets by a key.
The code from the video
List<Integer> nums = List.of(4, 1, 4, 7, 1, 9);
nums.stream().distinct().toList(); // [4, 1, 7, 9]
nums.stream().limit(3).toList(); // [4, 1, 4]
nums.stream().reduce(0, Integer::sum); // 26List<String> words = List.of("ant", "bee", "deer", "cat", "goat");
Map<Integer, List<String>> byLength = words.stream()
.collect(Collectors.groupingBy(String::length));
// {3=[ant, bee, cat], 4=[deer, goat]}Stream Storm, 9 out
1Java Streams Explained Visually: filter, map, flatMap, sorted1:212Java reduce() and groupingBy() Explained Visually1:373This toMap() Call Crashes Your Java Code (and the Fix)1:504Java Stream anyMatch, findFirst, takeWhile: How Streams Stop Early2:215Java IntStream and mapToInt Explained: The Hidden Boxing Cost1:586Java Parallel Streams Explained: When They Are Faster (and When Not)2:007Find average of numbers in a list0:578Find if element exists in a list using anyMatch()1:009Free Java Streams Interview PDFs (Top 20, 50, 100)0:58Keep going
More Shorts.
This toMap() Call Crashes Your Java Code (and the Fix) | Stream Storm Part 3, Short.
Java Streams Explained Visually: filter, map, flatMap, sorted | Stream Storm Part 1, Short.
Free Java Streams Interview PDFs (Top 20, 50, 100) | Stream Storm, Short.
Java Parallel Streams Explained: When They Are Faster (and When Not), Short.
