Java Lambda - DoubleConsumer accept example








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;

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.