Consumer接口andThen方法执行问题
main:
accepctObject(new StringBuffer("hello world"), s->{
s.append("--> this is consumer");
System.err.println(s);
},s->{s.append("-->two operator");
System.out.println(s);});
public static void accepctObject(StringBuffer s,Consumer<StringBuffer> one,Consumer<StringBuffer> two){
one.andThen(two).accept(s);
}
输出:
hello world--> this is consumer-->two operator
hello world--> this is consumer
他的确先执行了第一个方法在执行的第二个方法 但出现打印顺序问题