Declare Consumer function via Lambda - Java Lambda Stream

Java examples for Lambda Stream:Consumer

Description

Declare Consumer function via Lambda

Demo Code



import java.util.function.Consumer;

public class ConsumerDemo {
  public static void main(String[] args) {
    Consumer<String> s = (String name) -> System.out.println("Your Name:" + name);
    s.accept("Aman");
    s.accept("Aman1");
  }//from  w  ww .  j a v  a 2s . c  om
}

Related Tutorials