Example usage for java.util.function Consumer accept

List of usage examples for java.util.function Consumer accept

Introduction

In this page you can find the example usage for java.util.function Consumer accept.

Prototype

void accept(T t);

Source Link

Document

Performs this operation on the given argument.

Usage

From source file:Main.java

public static void main(String[] args) {
    Consumer<String> c = (x) -> System.out.println(x.toLowerCase());
    c.accept("Java2s.com");
}

From source file:Main.java

public static void main(String[] argv) {
    Util util = new Util();

    Consumer<String> consumer = str -> util.print(str);
    consumer.accept("Hello");

    Consumer<String> consumer1 = util::print;
    consumer1.accept("java2s.com");

    util.debug();/*from  ww  w  .j  a  va2s. c o  m*/
}

From source file:Main.java

public static void main(String... args) {
    Consumer<Person> greeter = (p) -> System.out.println("Hello, " + p.firstName);
    greeter.accept(new Person("First", "Last"));
}

From source file:Main.java

public static void main(String[] args) {
    Message message = new Message("java2s.com");
    Person person = new Person("Peter");

    Consumer<Message> messageConsumer = (t) -> System.out.println(t);
    messageConsumer.accept(message);

    Consumer<Person> personConsumer = (t) -> System.out.println(t);
    personConsumer.accept(person);/*from w  ww  .ja  v  a2  s.c o  m*/

}

From source file:Main.java

public static void main(String[] args) {
    int x = 99;/* ww  w  .j  a v  a2 s .c om*/

    Consumer<Integer> myConsumer = (y) -> {
        System.out.println("x = " + x); // Statement A
        System.out.println("y = " + y);
    };

    myConsumer.accept(x);
}

From source file:Main.java

public static void main(String[] args) {
    Consumer<Trade> consumer = x -> x.setQuantity(x.getQuantity() * 2);
    Trade t = new Trade(1, "XT", 1000, "NEW");
    System.out.println("T's qty before :" + t.getQuantity());
    consumer.accept(t);
    System.out.println("T's qty after :" + t.getQuantity());
}

From source file:Main.java

public static void sayBrand(Consumer<String> block, String param) {
    block.accept(param);
}

From source file:Main.java

public static void acceptAllEmployee(List<Student> student, Consumer<Student> printer) {
    for (Student e : student) {
        printer.accept(e);
    }// www .jav  a  2 s  . c  o  m
}

From source file:Main.java

public static void acceptAllEmployee(List<Employee> employees, Consumer<Employee> printer) {
    for (Employee e : employees) {
        printer.accept(e);
    }/*from ww w  .java2 s .  c  o  m*/
}

From source file:Main.java

private static void raiseStudents(List<Student> employees, Consumer<Student> fx) {
    for (Student e : employees) {
        fx.accept(e);
    }/*from   ww  w  .  java  2 s.c  om*/
}