ToLongFunction applyAsLong example

Description

ToLongFunction applyAsLong applies this function to the given argument.

Syntax

applyAsLong has the following syntax.


long applyAsLong(T value)

Example

The following example shows how to use applyAsLong.


import java.util.function.ToLongFunction;
//w w  w  .j a  v a2 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.