1、Function
定义
public interface Function <T, R>
Represents a function that accepts one argument and produces a result.
(表明接受一个参数和产生一个结果的function)
T: the type of the input to the function(入参类型)
R: the type of the result of the function(出参类型)
调用函数
R apply(T t);
使用举例
// 入参+1
Function<Integer, Integer> incrFunc = p -> p + 1;
// ret=7
Integer ret = incrFunc.apply(6);
2、Consumer
定义
public interface Consumer<T>
Represent an operation that accepts a single input argument and returns no result
(表明接受一个参数无返回结果的operation,通常用于处理意外情况或额外动作)
T: the type of the input to the function(入参类型)
调用函数
voi