DoubleSupplier getAsDouble example

Description

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;
//from w  w w.  j  av  a  2s .c  o  m
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.