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.


  1. LongToIntFunction applyAsInt


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;

The code above generates the following result.