Java Lambda - LongSupplier example








LongSupplier represents a supplier of long-valued results. This is the long-producing primitive specialization of Supplier.

Method

  1. LongSupplier getAsLong

Example

The following example shows how to use LongSupplier.

import java.util.function.LongSupplier;
/*  w w  w .  j av  a 2  s .  co  m*/
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.