Exploring Collectors
summary
Walks through concrete Java Stream code showing where Collectors replace error-prone reduce/for-each patterns, demonstrates Collectors utility class methods (toList/toSet/toUnmodifiableList, joining, groupingBy, partitioningBy, mapping, counting, collectingAndThen, maxBy/minBy, teeing, flatMap) and live-codes conversions (map→collect, map+flatMap, grouping to buckets, counting yields Long→int via collectingAndThen). Reproduces a race bug from shared mutation and proves collectors work with parallel streams, argues to avoid shared mutability and prefer immutable collectors for correct, concurrent results.
AI-written summary · about
chapters (22)
- 0:00Introduction
- 1:18Why Java
- 2:37Create People
- 8:23Reduce
- 14:04Lazy Evaluation
- 15:00Immutability
- 16:32Programming languages
- 17:39Example
- 23:58Reduce Function
- 25:12Combine Collections
- 29:37Collectors
- 33:34Using Collectors
- 35:27Creating a Map
- 38:10Create a Map
- 40:01Get a List of Ages
- 41:08Unmodifiable Lists
- 42:31commaseparated lists
- 45:30collecting
- 47:07filters
- 50:20partitioning
- 52:04by name
- 54:07add
related talks
55mExploring Collectors
53mExploring Collectors: A Powerful Utility Class in the JDK
01h 57mJourney’s End: Collection and Reduction in the Streams API
02h 47mCollectors in the wild!
44mI didn't know you could do that with Java Streams!
01h 01mTransforming Data using the Functional API
51mIf Streams Are So Great, Let’s Use Them Everywhere... Right??
44mThinking in Streams
