Java Lambda - DoubleSupplier getAsDouble example








DoubleSupplier getAsDouble gets result from the functional interface.

Syntax

getAsDouble has the following syntax.

double getAsDouble()

Example

The following example shows how to use getAsDouble.

import java.util.function.DoubleSupplier;
/*ww w  .  j  av  a2 s.  c  om*/
public class Main {

  public static void main(String[] args) {
    DoubleSupplier pi = () -> {return 3.14d;};

   
    System.out.println(pi.getAsDouble());
  }
}

The code above generates the following result.