IntUnaryOperator applyAsInt example

Description

IntUnaryOperator applyAsInt applies this operator to the given operand.

Syntax

applyAsInt has the following syntax.


int applyAsInt(int operand)

Example

The following example shows how to use applyAsInt.


import java.util.function.IntUnaryOperator;
//  w  ww  .  j  ava 2s  .  c  o 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.