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.

Method

  1. IntConsumer accept
  2. IntConsumer andThen




Example

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);
    
    ic.accept(3);

  }
}

The code above generates the following result.