Section 08 ยท Stage 3: Master Java
Streams & Modern Java
The Stream API, Optional, method references, the Date and Time API and other modern Java features used in real code and interviews.
What you will be able to do
- Use the built-in functional interfaces and every kind of method reference with confidence
- Rewrite loops as clear stream pipelines and know when a loop is still better
- Group, count and summarise data with collectors
- Use Optional correctly and avoid its common misuse
- Work with dates, times and time zones using java.time
- Model data with records and sealed types and handle it with Java 21 pattern matching
What you will learn
8.1Functional Interfaces in Practice9 lessons
The ready-made interfaces in java.util.function, how to combine them and the rules lambdas follow.
- The java.util.function package30 min
- Function and Predicate30 min
- Consumer and Supplier30 min
- BiFunction, UnaryOperator and BinaryOperator35 min
- Primitive functional interfaces35 min
- Combine functions and predicates35 min
- Effectively final variables in lambdas35 min
- Write your own functional interface40 min
- Functional interfaces: mistakes and practice45 min
8.2Method References in Depth7 lessons
All four kinds of method reference, how the compiler matches them, and when a lambda reads better.
8.3Stream Basics7 lessons
What a stream is, how a pipeline runs, why streams are lazy, and how a stream compares with a loop.
8.4Transforming Streams9 lessons
The intermediate operations you will use every day, and how to order them in a clean pipeline.
8.5Terminal Operations & Reduction8 lessons
Get a result out of a stream: a value, a list, a check or a single combined answer.
8.6Collectors9 lessons
Build maps, groups and reports from streams in one pipeline.
- collect and the Collectors class30 min
- toMap and duplicate keys40 min
- Group data with groupingBy35 min
- Downstream collectors40 min
- Summary statistics and teeing35 min
- Split data with partitioningBy30 min
- joining, mapping and filtering collectors40 min
- Sorted and nested grouping45 min
- Collectors: practice45 min
8.7Primitive & Parallel Streams8 lessons
Number streams, generated streams and an honest look at parallel streams and stream pitfalls.
- IntStream, LongStream and DoubleStream30 min
- Number ranges with IntStream.range30 min
- Stream.iterate and Stream.generate30 min
- Side effects and why they break streams35 min
- Parallel streams40 min
- When parallel streams help and hurt40 min
- Stream pitfalls, readability and performance40 min
- Primitive and parallel streams: practice45 min
8.8Optional7 lessons
Return "maybe a value" safely instead of null, and avoid the usual Optional mistakes.
8.9Date & Time API8 lessons
Handle dates, times, durations and time zones correctly with java.time.
8.10Records & Sealed Types in Practice8 lessons
Use records for real data and sealed classes and interfaces to close a type hierarchy.
- Records as data carriers in streams35 min
- Validation and factory methods in records40 min
- Nested and local records40 min
- Sealed classes and permits35 min
- final, sealed and non-sealed subclasses35 min
- Sealed interfaces with records40 min
- Model results with sealed types45 min
- Records and sealed types: practice50 min
8.11Pattern Matching & Newer Language Features10 lessons
Java 17 to 21 features: patterns in instanceof and switch, record patterns, var, text blocks and sequenced collections.
- Pattern matching for instanceof30 min
- Type patterns in switch35 min
- Guards with when35 min
- Exhaustive switch and case null35 min
- Record patterns and deconstruction40 min
- var: local type inference30 min
- Text blocks for multi-line strings30 min
- Sequenced collections30 min
- Handy Java 11 to 17 additions30 min
- Modern Java features: practice45 min
8.12Modern Java Mini Projects5 lessons
Small projects that use streams, collectors, Optional, java.time, records and sealed types together.
