Java Lambda - IntUnaryOperator andThen example

IntUnaryOperator andThen returns a composed operator that first applies this operator to its input, and then applies the after operator to the result.


andThen has the following syntax.

default IntUnaryOperator andThen(IntUnaryOperator after)


The following example shows how to use andThen.

import java.util.function.IntUnaryOperator;

public class Main {

  public static void main(String[] args) {
    IntUnaryOperator i = (x) -> x*x;

The code above generates the following result.