Java Lambda - DoubleSupplier example

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


  1. DoubleSupplier getAsDouble


The following example shows how to use DoubleSupplier.

import java.util.function.DoubleSupplier;
/*  www . j a v a  2  s.  c o m*/
public class Main {

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


The code above generates the following result.