Create Consumer Lambda with method reference - Java Lambda Stream

Java examples for Lambda Stream:Consumer

Description

Create Consumer Lambda with method reference

Demo Code



import java.util.function.Consumer;

public class ConsumerFunctionalInterface {
  static void show(String name) {
    System.out.println("Name:" + name);
  }/*from  w  w  w.ja  v  a2  s .  com*/

  public static void main(String[] args) {
    Consumer<String> consumer = ConsumerFunctionalInterface::show;
    consumer.accept("Aman");
    consumer.accept("Sonu");
    consumer.accept(null);
    consumer.accept("Raman");
  }

}

Related Tutorials