Java Lambda - IntConsumer accept example








IntConsumer accept performs this operation on the given argument.

Syntax

accept has the following syntax.

void accept(int value)

Example

The following example shows how to use accept.

import java.util.function.IntConsumer;
// w  ww  .  jav a2 s.  c  om
public class Main {

  public static void main(String[] args) {
    IntConsumer ic = (x)->System.out.println(x);
    
    ic.accept(3);

  }
}

The code above generates the following result.