Pages

Topics

Tools

↑↓navigate↵openescclose

Java guides

Every published Java guide, newest first, with practical examples you can copy into your own project.

3,965 guides across 14 topics

Topics

Latest Java guides

Illustration comparing Java Function and Consumer interfaces with arrows showing transformation versus side-effect.
Java

Java Function vs Consumer: Key Differences

java function vs consumer: Understand the practical differences between Java's Function and Consumer interfaces, when to use each, and how they fit into functional pip...

JavaFunctional InterfacesLambda ExpressionsStreams API
Illustration comparing map and flatMap on Java's Optional, showing how flatMap flattens a nested Optional into a single container.
Java

Java Optional map vs flatMap: Key Differences

Understand the difference between map and flatMap on Java's Optional, when to use each, and how to avoid nested Optional pitfalls.

OptionalflatMapJavafunctional programming
Diagram comparing Java Optional orElse and orElseGet evaluation timing
Java

Java Optional orElse vs orElseGet

Java Optional orElse vs orElseGet: Understand the difference between eager and lazy evaluation and when to use each fallback approach.

Java OptionalorElseorElseGetLazy Evaluation
Illustration comparing sequential and parallel Java streams with a fork-join split
Java

Java Stream vs Parallel Stream: When to Use Each

Understand the tradeoffs between sequential and parallel streams in Java, including performance, shared state, ordering, and when to use each.

Java StreamsParallelismForkJoinPoolPerformance
A split diagram showing a Java stream flowing into two different list containers, one mutable and one immutable, representing the comparison between Stream.toList() and Collectors.toList().
Java

Java Stream toList vs Collectors.toList

java stream tolist vs collectors tolist: Compare Java's Stream.toList() and Collectors.toList(): mutability, null handling, performance, and when to use each terminal...

Java StreamsCollectorsJava 16List
A visual comparison of Java Stream reduce and collect terminal operations.
Java

Java Stream reduce vs collect: Key Differences

Understand the key differences between Java Stream reduce and collect, including how each terminal operation works and when to choose one over the other.

Java Streamsreducecollectterminal operations
Diagram contrasting anyMatch and allMatch short-circuit evaluation in Java Streams
Java

Java Stream anyMatch vs allMatch: Key Differences

Understand the difference between Java Stream anyMatch and allMatch: short-circuiting, empty stream results, validation use cases, and common mistakes.

Java StreamsanyMatchallMatchShort-Circuiting
Illustration comparing Java Stream findFirst and findAny operations, showing order sensitivity and parallel performance.
Java

Java Stream findFirst vs findAny: Key Differences

Understand the difference between Java Stream findFirst and findAny, including their behavior in sequential and parallel streams and when to choose each.

Java StreamsfindFirstfindAnyParallel Streams
Side-by-side illustration of Java Stream filter and map operations transforming a stream of elements.
Java

Java Stream filter vs map: Key Differences

Understand the difference between Java Stream filter and map operations, when to use each, and how they combine in functional pipelines.

Java Streamsfilter operationmap operationintermediate operations
Diagram showing map transforming each element and flatMap flattening nested streams
Java

Java Stream map vs flatMap: Key Differences

Learn the difference between Java Stream map and flatMap, when to use each, and how they affect stream processing.

Java StreamsmapflatMapfunctional programming