Skip to content

Consumers

Rahul Chhabra edited this page Jun 13, 2017 · 1 revision

What are Consumers?

A consumer is a lambda interface that "consumes" all of it's arguments,i.e,it does not return anything.

Using TriConsumer

TriConsumer<String, String, String> printString = (t, u, v) -> {
        System.out.println(t);
        System.out.println(u);
        System.out.println(v);
};
printString.accept("Hello World", "How are you?", "I'm good");

The three strings will be printed. QuadriConsumer is used in the same way, except it takes four arguments.

Clone this wiki locally