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

Diagram illustrating four types of Java method references: static, instance on object,, instance on arbitrary object, and constructor.
Java

Java Method Reference Syntax

Understand Java method references by learning the four forms, their lambda equivalents, and when each form is most useful.

method referenceslambda expressionsfunctional interfacesJava syntax
Editorial illustration of a Java method reference connecting a lambda expression to a named method through the double-colon operator.
Java

Java Method Reference: Syntax and Practical Usage

Learn the four forms of Java method references, how each maps to a lambda expression, and when each form fits cleanly in production code.

JavaLambda ExpressionsFunctional InterfacesStream API
Diagram showing the execution order of Function.compose and andThen in Java.
Java

Java Function compose and andThen: Ordering and Usage

Understand the difference between Function.compose and Function.andThen: their execution order, practical examples, and when to use each for readable functional pipelines.

functional-programmingjava-streamslambda-expressionsfunction-composition
Illustration of Java Consumer and Supplier functional interfaces showing input and output flow.
Java

Java Consumer vs Supplier: When to Use Each

Java's Consumer and Supplier functional interfaces solve opposite problems: Consumer accepts a value and returns nothing, while Supplier takes no input and produces a value. See when to use each with Java examples.

JavaFunctional InterfacesLambda ExpressionsStreams
A visual comparison of Java's Predicate and Function interfaces showing boolean output versus value transformation.
Java

Java Predicate vs Function: Key Differences

Compare Java's Predicate<T> and Function<T,R> interfaces: signatures, return types, composition methods, and when to use each in real code.

Java functional interfacesjava.util.functionLambda expressionsStream API
A Java BinaryOperator combining two blocks into a single result, representing the reduction of two inputs into one output.
Java

Using Java BinaryOperator for Concise Reductions

Learn how Java's BinaryOperator simplifies same-type two-argument operations, with practical stream reduction examples, `andThen` composition, and common pitfalls.

JavaFunctional InterfacesLambda ExpressionsStreams
Diagram showing a unary operator transforming an input value to an output value in Java
Java

Java UnaryOperator: Usage and Examples

Learn how to use Java's UnaryOperator functional interface with lambdas, method references, and composition for clean, reusable transformations.

Functional InterfacesLambda ExpressionsMethod ReferencesJava Streams
Illustration of a Java BiPredicate combining two input values into a single boolean result through a logical gate.
Java

Java BiPredicate: Two-Argument Predicates in Practice

Java's BiPredicate is the two-argument counterpart to Predicate. See how to construct, compose, and use it with streams and validation rules, plus common edge cases.

JavaFunctional InterfacesLambda ExpressionsStreams
Illustration of Java BiConsumer accepting two arguments and performing an operation
Java

Java BiConsumer: Syntax, Usage, and Common Patterns

Learn how to use Java's BiConsumer functional interface for two-argument operations, including syntax, chaining, and practical examples.

JavaFunctional InterfaceLambda ExpressionsBiConsumer
Diagram showing two inputs flowing into a BiFunction and producing a single output, with a lambda symbol.
Java

Java BiFunction: Syntax, Usage, and Examples

Learn how to use Java BiFunction with lambda expressions, method references, and composition. See practical examples and avoid common pitfalls.

functional programminglambda expressionsBiFunctionmethod references