Java Lambda - LongToIntFunction applyAsInt example








LongToIntFunction applyAsInt applies this function to the given argument.

Syntax

applyAsInt has the following syntax.

int applyAsInt(long value)

Example

The following example shows how to use applyAsInt.

import java.util.function.LongToIntFunction;
// w  w w .java2s  .  co m
public class Main {

  public static void main(String[] args) {
    LongToIntFunction i = (l) -> (int)l;
    
    System.out.println(i.applyAsInt(Long.MAX_VALUE));
  }
}

The code above generates the following result.