IntUnaryOperator andThen example
Description
IntUnaryOperator andThen returns a composed operator that first applies this operator to its input, and then applies the after operator to the result.
Syntax
andThen
has the following syntax.
default IntUnaryOperator andThen(IntUnaryOperator after)
Example
The following example shows how to use andThen
.
import java.util.function.IntUnaryOperator;
//w w w .ja va 2 s. c om
public class Main {
public static void main(String[] args) {
IntUnaryOperator i = (x) -> x*x;
System.out.println(i.andThen(i).applyAsInt(2));
}
}
The code above generates the following result.
Home »
Java Lambda »
java.util.function Reference »
Java Lambda »
java.util.function Reference »