Consumer example
Description
Consumer interface represents an operation that accepts a single input argument and returns no result.
Example
The following example shows how to use Consumer
.
import java.util.function.Consumer;
/* www . ja 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 »