Java Lambda - BiConsumer accept example








Performs BiConsumer operation on the given arguments.

Syntax

accept has the following syntax.

void accept(T t, U u)

Example

The following example shows how to use accept.

import java.util.function.BiConsumer;
//from www . j  a  v a  2s  .  c  o  m
public class Main {
  public static void main(String[] args) {
    BiConsumer<String, String> biConsumer = (x, y) -> {
      System.out.println(x);
      System.out.println(y);
    };

    biConsumer.accept("java2s.com", " tutorials");
  }
}

The code above generates the following result.