Java Lambda - ToLongFunction example








ToLongFunction represents a function that produces a long-valued result. This is the long-producing primitive specialization for Function.

Method

  1. ToLongFunction applyAsLong

Example

The following example shows how to use ToLongFunction.

import java.util.function.ToLongFunction;
// w  w  w.j  a  va2 s  .c o  m
public class Main {

  public static void main(String[] args) {
    ToLongFunction<String> i  = (x)-> Long.parseLong(x);
    
    System.out.println(i.applyAsLong("2"));
  }
}

The code above generates the following result.