Pass IntConsumer as parameter

Description

The following code shows how to pass IntConsumer as parameter.

Example


import java.util.function.IntConsumer;
//from ww w  . j av  a 2  s .c  o  m
public class Main {
  public static void start(IntConsumer cons, int d) {
    cons.accept(d);
  }
  public static void main(String[] args) {
    start(e -> System.out.print("Release year: " + e), 2013);
  }
}

The code above generates the following result.





















Home »
  Java Streams »
    Examples »




Average
Filter
Group
IntStream
Map
Partition
Reduce
Sort
Sum