Functional Programming
Java 8 added lambdas, the Streams API, and functional interfaces — transforming how Java developers write and read data-processing code. Mastering the stream pipeline, understanding lazy evaluation, and knowing when to prefer functional style over imperative loops are skills expected at every seniority level.
What You'll Find Here
Notes are being added. Planned topics:
| Topic | Description |
|---|---|
| Lambdas | (params) -> expression syntax, effectively-final capture, this behavior. |
| Functional Interfaces | @FunctionalInterface, Function, Predicate, Consumer, Supplier. |
| Method References | Static, instance, constructor references — when to prefer over lambdas. |
| Streams API | Pipeline anatomy — source, intermediate ops (filter, map, flatMap), terminal ops. |
| Collectors | toList, groupingBy, joining, counting, custom collectors. |
| Parallel Streams | When parallel helps vs. hurts — ordering, side effects, ForkJoin pool. |
| Optional Deep Dive | Correct usage patterns; anti-patterns (field types, method parameters). |
Learning Path
- Lambdas — understand syntax and effectively-final capture before going further.
- Functional Interfaces —
Function<T,R>,Predicate<T>, andConsumer<T>are the backbone of the Streams API. - Streams API — the pipeline model (lazy evaluation + one terminal op) is the core concept.
- Collectors —
groupingByandtoMapare the collectors most likely to appear in interviews. - Parallel Streams — study AFTER understanding sequential streams; parallelism introduces correctness risks.
Related Domains
- Java Type System — lambdas rely on generic functional interfaces and wildcard inference.
- Collections Framework — streams operate on collections; know both approaches.
- Multithreading & Concurrency — parallel streams use the ForkJoin pool under the hood.