DoubleConsumer accept example

Description

DoubleConsumer accept performs passedin operation on the given argument.

Syntax

accept has the following syntax.


void accept(double value)

Example

The following example shows how to use accept.


import java.util.function.DoubleConsumer;
// w ww.  j  av a2 s . c  o  m
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.