Java Lambda - LongSupplier getAsLong example








LongSupplier getAsLong gets a result.

Syntax

getAsLong has the following syntax.

long getAsLong()

Example

The following example shows how to use getAsLong.

import java.util.function.LongSupplier;
/*ww w.j  a  v a  2 s .c  om*/
public class Main {

  public static void main(String[] args) {
    LongSupplier i = () -> Long.MAX_VALUE;
    
    System.out.println(i.getAsLong());
  }
}

The code above generates the following result.