LongUnaryOperator compose example
Description
LongUnaryOperator compose returns a composed operator that first applies the before operator to its input, and then applies this operator to the result.
Syntax
compose
has the following syntax.
default LongUnaryOperator compose(LongUnaryOperator before)
Example
The following example shows how to use compose
.
import java.util.function.LongUnaryOperator;
//from ww w . ja va 2 s. co m
public class Main {
public static void main(String[] args) {
LongUnaryOperator i = (l) -> -l;
LongUnaryOperator j = (l) -> l/2;
System.out.println(i.compose(j).applyAsLong(Long.MAX_VALUE));
}
}
The code above generates the following result.
Home »
Java Lambda »
java.util.function Reference »
Java Lambda »
java.util.function Reference »