Consumer accept example
Description
Consumer accept performs operation on the given argument.
Syntax
accept
has the following syntax.
void accept(T t)
Example
The following example shows how to use accept
.
import java.util.function.Consumer;
/* w ww . j a va 2 s .c o m*/
public class Main {
public static void main(String[] args) {
Consumer<String> c = (x) -> System.out.println(x.toLowerCase());
c.accept("Java2s.com");
}
}
The code above generates the following result.
Home »
Java Lambda »
java.util.function Reference »
Java Lambda »
java.util.function Reference »