DoubleConsumer example

Description

DoubleConsumer functional interface represents an operation that accepts a single double-valued argument and returns no result. This is the primitive type specialization of Consumer for double.

Example

The following example shows how to use DoubleConsumer.


import java.util.function.DoubleConsumer;
//w  w  w  . j  av  a 2 s  .  c  om
public class Main {
  public static void main(String[] args) {
    DoubleConsumer d = (x) -> System.out.println(x*x);
    d.accept(0.23);
  }
}

The code above generates the following result.