How do the consumer and begin methods work within the Java functional interface
•
Java
Who can let me know how the following procedures work internally:
public class Main {
public static void main(String[] args) {
Consumer<String> c = (x) -> System.out.println(x.toLowerCase());
c.andThen(c).andThen(c).accept("Java2s.com");
}
}
Solution
The document consumer#andthen says:
This means that your consumer will be accepted 3 times, such as:
v--- 1. c.accept("Java2s.com");
c.andThen(c).andThen(c).accept("Java2s.com");
^ ^
| |
| 3. c.accept("Java2s.com");
|
2. c.accept("Java2s.com");
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
