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

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

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

public class Main {

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

}