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.
The following example shows how to use IntUnaryOperator
.
import java.util.function.IntUnaryOperator; 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.