IntUnaryOperator identity example
Description
IntUnaryOperator identity returns a unary operator that always returns its input argument.
Syntax
identity
has the following syntax.
static IntUnaryOperator identity()
Example
The following example shows how to use identity
.
import java.util.function.IntUnaryOperator;
/*from w w w .jav a2s . c o m*/
public class Main {
public static void main(String[] args) {
IntUnaryOperator i = IntUnaryOperator.identity();
System.out.println(i.compose(i).applyAsInt(2));
}
}
The code above generates the following result.
Home »
Java Lambda »
java.util.function Reference »
Java Lambda »
java.util.function Reference »