Consumer andThen example
Description
Consumer andThen returns a composed Consumer that performs, in sequence, for the current operation followed by the after operation.
Syntax
andThen
has the following syntax.
default Consumer<T> andThen(Consumer<? super T> after)
Example
The following example shows how to use andThen
.
import java.util.function.Consumer;
/* w ww. ja va2s . c o m*/
public class Main {
public static void main(String[] args) {
Consumer<String> c = (x) -> System.out.println(x.toLowerCase());
c.andThen(c).accept("Java2s.com");
}
}
The code above generates the following result.
Home »
Java Lambda »
java.util.function Reference »
Java Lambda »
java.util.function Reference »