This is a 3-week hands-on training roadmap for mastering Java Functional Programming and Stream API. Designed for 2–3 hours/day of practice, progressing from basics to advanced concepts with mini-projects.
Goal: Understand lambdas, functional interfaces, method references, and core FP concepts.
-
Learn:
@FunctionalInterface- Lambda syntax
(params) -> expression
-
Practice:
- Implement
Runnable,Comparator, and a custom functional interface. - Example: Calculator interface for
add,subtract,multiply.
- Implement
-
Learn:
ClassName::staticMethodinstance::methodClassName::new(constructor references)
-
Practice:
-
Convert existing lambdas to method references.
-
Example:
List<String> names = List.of("Alice","Bob"); names.forEach(System.out::println);
-
-
Learn:
Predicate<T>→ test conditionsConsumer<T>→ accept valuesSupplier<T>→ provide valuesFunction<T,R>→ transform values
-
Practice:
- Filter strings by length using Predicate
- Generate random numbers with Supplier
- Print values with Consumer
-
Learn:
Optional<T>to avoidNullPointerException
-
Practice:
- Wrap variables in Optional
- Use
ifPresent(),orElse(),map()
-
Build a functional utility class with:
- Filtering, mapping, aggregating, and null-safe methods.
-
Practice chaining functional interfaces.
-
Example:
UserUtils.filterActiveUsers(users) .map(User::getEmail) .forEach(System.out::println);
Goal: Process collections in a functional style.
-
Learn:
stream(),parallelStream(),of(),Arrays.stream() -
Practice:
- Convert list/array to stream and print elements.
-
Learn:
filter(),map(),peek() -
Practice:
- Filter even numbers, square them, print intermediate results.
-
Learn:
reduce()→ aggregate,collect()→ gather results -
Practice:
- Sum, multiply, max, min
- Collect to
List,Set, orMap
-
Learn:
sorted(),distinct(),limit(),skip() -
Practice:
- Sort numbers descending
- Remove duplicates from a list
-
Learn:
Collectors.groupingBy(),Collectors.partitioningBy() -
Practice:
- Group
Personobjects by age - Partition even and odd numbers
- Group
-
Learn: Flatten nested collections
-
Practice:
- Flatten
List<List<Integer>>intoList<Integer> - Flatten a
List<Person>each havingList<Address>
- Flatten
-
Task: Build a data processor:
-
Input: List of Employees (name, dept, salary)
-
Output:
- Employees per department
- Highest salary per department
- List of names with salary > 5000
-
Goal: Apply FP & Stream API in real scenarios.
-
Learn:
parallelStream(),spliterator() -
Practice:
- Compare
stream()vsparallelStream()performance on large lists
- Compare
-
Learn:
joining(),summarizingInt(),mapping(),toMap() -
Practice:
- Create comma-separated names
- Count employees per department
-
Learn: Stream concatenation, Stream from
Optional -
Practice:
- Merge two lists, filter, sort
-
Learn: Immutability, pure functions, higher-order functions
-
Practice:
- Create pure transformation functions for lists
-
Learn: Wrap checked exceptions in lambdas
-
Practice:
- Read file lines with
Files.lines().stream()and handle exceptions functionally
- Read file lines with
-
Task: Employee Analytics App
-
Input:
List<Employee>(id, name, dept, salary) -
Features:
- Filter by salary range
- Group by department and calculate avg salary
- Find top 3 highest-paid employees
- Flatten nested projects per employee
- Produce summary report
-
- Use IntelliJ IDEA or Eclipse for functional shortcuts.
- Try to chain operations instead of writing loops.
- Keep a practice notebook of examples.
- Refactor imperative code to functional style wherever possible.
- Check JavaDocs for Stream API and Collectors – they have ready examples.