DoubleSupplier example

Description

DoubleSupplier represents a supplier of double-valued results. This is the double-producing primitive specialization of Supplier.

Example

The following example shows how to use DoubleSupplier.


import java.util.function.DoubleSupplier;
/* w w  w  . j a  va2 s .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.