OO Programming with Java


Advanced Concepts

Complement 2. andThen corresponds to function composition:

import java.util.function.*;
public class Funs {
  public static void main(String[] args) {
    Function<Integer,Integer> f,g;
    f = x->x+1; 
    g = f.andThen(x->x*2);
    System.out.println(g.apply(1));
  }
}

8 - 17