Java Lambda - LongFunction example








LongFunction represents a function that accepts a long-valued argument and produces a result. This is the long-consuming primitive specialization for Function.

Method

  1. LongFunction apply

Example

The following example shows how to use LongFunction.

import java.util.function.LongFunction;
//ww  w.j  a  va 2  s. c  om
public class Main {

  public static void main(String[] args) {
    LongFunction<String> i = (l) -> Long.toString(l);
    
    System.out.println(i.apply(Long.MAX_VALUE));
  }
}

The code above generates the following result.