IntUnaryOperator example
Description
IntUnaryOperator represents an operation on a single int-valued operand that produces an int-valued result. This is the primitive type specialization of UnaryOperator for int.
Example
The following example shows how to use IntUnaryOperator
.
import java.util.function.IntUnaryOperator;
/* w w w. j a v a2 s . co m*/
public class Main {
public static void main(String[] args) {
IntUnaryOperator i = (x) -> x*x;
System.out.println(i.applyAsInt(2));
}
}
The code above generates the following result.
Home »
Java Lambda »
java.util.function Reference »
Java Lambda »
java.util.function Reference »