DevNotes
Support
Java · 22 chapters

Java 8 & Streams

Streams from basics to internals: filter, map, sorting, reduce, collectors, groupingBy, flatMap, Optional, primitive streams, functional interfaces, method references, parallel streams, custom collectors, Spliterator and the java.time API.

CHAPTER 01

Stream Basics

What a Stream is, Collection vs Stream, internal iteration, the source → intermediate → terminal pipeline, laziness and reuse.

6 min · 5 Q&A · 14 examples
CHAPTER 02

Filtering

filter() with Predicates, findFirst vs findAny, anyMatch/allMatch/noneMatch and short-circuiting — with Spring Boot examples.

6 min · 6 Q&A · 19 examples
CHAPTER 03

Mapping

Transforming elements with map(), Entity → DTO conversion, method references and primitive mapping with mapToInt/Long/Double.

6 min · 4 Q&A · 20 examples
CHAPTER 04

Sorting

sorted(), natural and reverse order, Comparator.comparing, thenComparing, nulls handling, stability and top-N patterns.

7 min · 5 Q&A · 23 examples
CHAPTER 05

distinct(), limit() and skip()

Removing duplicates, taking the first N, offsetting, pagination with skip + limit, order of operations and Nth-highest problems.

7 min · 10 Q&A · 24 examples
CHAPTER 06

Reduction Operations

Combining a stream into one value — reduce() forms, identity/accumulator/combiner, sum, count, max, min, average and parallel reduction.

6 min · 5 Q&A · 15 examples
CHAPTER 07

Collectors

Turning streams into results — toList, toSet, toMap (and duplicate keys), joining, counting, summing, averaging and summarizing.

7 min · 5 Q&A · 19 examples
CHAPTER 08

groupingBy() and partitioningBy()

The most important Stream topic — grouping by a key, downstream collectors, counting/summing/averaging per group, multi-level grouping and true/false partitions.

7 min · 5 Q&A · 19 examples
CHAPTER 09

Advanced Collectors

Combining collectors like Lego blocks — collectingAndThen, mapping, filtering, flatMapping, reducing, teeing and nested collector pipelines.

7 min · 5 Q&A · 17 examples
CHAPTER 10

flatMap()

The most misunderstood Stream operation — flattening nested collections, map() vs flatMap(), chained flatMap, flatMapToInt and null-safe flattening.

7 min · 4 Q&A · 26 examples
CHAPTER 11

Real Stream Interview Problems

From APIs to problem solving — duplicates, frequencies, first non-repeating element, Nth highest, longest string, per-department analytics and anagrams.

7 min · 5 Q&A · 17 examples
CHAPTER 12

Optional

Making absence explicit — of vs ofNullable, why get() is dangerous, ifPresent, orElse vs orElseGet, orElseThrow, and map/filter/flatMap on Optional.

5 min · 5 Q&A · 21 examples
CHAPTER 13

Primitive Streams

IntStream, LongStream and DoubleStream — why they exist, boxing overhead, sum/average/max/min, summaryStatistics, boxed() and OptionalInt.

6 min · 6 Q&A · 18 examples
CHAPTER 14

Generating Streams

Creating streams without a collection — range(), rangeClosed(), iterate(), generate(), infinite streams, Fibonacci, UUIDs and business days.

7 min · 5 Q&A · 22 examples
CHAPTER 15

Functional Interfaces

The engine behind Streams — @FunctionalInterface, lambdas, Predicate, Function, Consumer, Supplier, UnaryOperator, BinaryOperator, composition and chaining.

8 min · 6 Q&A · 30 examples
CHAPTER 16

Method References

Every form of :: explained — static, specific-object, arbitrary-object and constructor references, array constructors, and when a lambda is better.

6 min · 5 Q&A · 17 examples
CHAPTER 17

Parallel Streams and Performance

How parallelStream() works — Fork/Join, the common pool, ordering, thread safety, associativity, and when parallel makes things slower.

7 min · 6 Q&A · 19 examples
CHAPTER 18

Custom Collectors

The secret behind Collectors.toList() — supplier, accumulator, combiner, finisher, characteristics, and writing your own with Collector.of().

6 min · 5 Q&A · 11 examples
CHAPTER 19

Spliterator and Stream Internals

What happens after list.stream() — Spliterator, trySplit, lazy evaluation, single-use streams, pipeline fusion, short-circuiting and characteristics.

7 min · 6 Q&A · 14 examples
CHAPTER 20

Java 8 Interview Masterclass

How interviewers think — core, Stream, Optional, functional interface, parallel, collector, method reference and internals questions, plus output-based puzzles.

6 min · 36 Q&A · 7 examples
CHAPTER 21

Date and Time API (java.time)

LocalDate, LocalTime, LocalDateTime, ZonedDateTime, Instant, Period, Duration and DateTimeFormatter — the immutable, thread-safe replacement for Date and Calendar.

5 min · 4 Q&A · 16 examples
CHAPTER 22

Stream API Cheat Sheet

Every commonly used Stream method on one page — creation, intermediate and terminal operations, primitive streams, collectors and parallel streams.

4 min · 0 Q&A · 1 examples