Java Stream How to - Pass IntConsumer as parameter








The following code shows how to pass IntConsumer as parameter.

Example

import java.util.function.IntConsumer;
//  ww w .  j a v  a  2  s  .co 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.