How do the consumer and begin methods work within the Java functional interface

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
分享
二维码
< <上一篇
下一篇>>