Java Lambda - IntUnaryOperator compose example

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


compose has the following syntax.

default IntUnaryOperator compose(IntUnaryOperator before)


The following example shows how to use compose.

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.