一 函数式编程
函数式编程是把动作作为参数对象传给调用的方法。
@Test
public void testAddThen() {
List<Integer> list = Arrays.asList(3, 1);
List<Integer> collect = list.stream()
// map 的入参是Function类型对象
// addThen 返回的是Function类型对象
// ((Function<Integer, Integer>) (item -> item * 3)) 是第一个Function 对象
// item -> item * 3 是第一个对象的apply实现动作
.map(((Function<Integer, Integer>) (item -> item * 3))
// andThen里面调用的是两次apply动作
// 第一次是 ((Function<Integer, Integer>) (item -> item * 3)) 他自己的apply动作
// 第二次是 item -> item + 2 andThen 这个方法的入参函数 的apply方法
.andThen(item -> item + 2))
.collect(Collectors.toList());
System.out.println(collect);
}