Java Lambda - IntConsumer example

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


  1. IntConsumer accept
  2. IntConsumer andThen


The following example shows how to use IntConsumer.

import java.util.function.IntConsumer;
/*  w ww.j  a v a2  s . c  om*/
public class Main {

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


The code above generates the following result.