Java8 Funtion学习 Posted on 2021-10-11 andThen先执行自己再执行入参函数,compose反之 1234567Function<Integer, Integer> f1 = n -> n * n; Function<Integer, Integer> f2 = n -> n * n * 3;System.out.println(f1.andThen(f2).apply(2));//先执行f1->2*2->4*4*3=48System.out.println(f1.compose(f2).apply(2));//先执行f2->2*2*3->12*12=144