首页javalambda_apiJava Stream - 如何create函数lambda和调用andThen方法

Java Stream - 如何create函数lambda和调用andThen方法

我们想知道如何create函数lambda和调用andThen方法。
import java.util.function.Function;

public class Main {

  public static void main(String[] args) {
    Function<Integer, Integer> incrementer = (n) -> n + 1;
    Function<Integer, Integer> after = (n) -> n - 1;
    System.out.println(incrementer.andThen(after).apply(2));
  }

}