Java Lambda - LongToIntFunction example








LongToIntFunction represents a function that accepts a long-valued argument and produces an int-valued result. This is the long-to-int primitive specialization for Function.

Method

  1. LongToIntFunction applyAsInt

Example

The following example shows how to use LongToIntFunction.

import java.util.function.LongToIntFunction;
//  w  ww .ja v  a2s.  c om
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.