定义在java.util.function包中
Function和BiFunction接口
public interface Function<T, R>{
R apply(T argument);
}
public interface BiFuncion<T, U, R>{
R apply(T argument1, R argument2);
}
表示带一个(两个)参数且返回一个结果的函数,结果类型可与参数类型不同
Predicate接口
public interface Predicate<T>{
boolean test(T t);
}
带一个参数的函数,基于参数值返回true或false
Supplier接口
public interface Supplier<T>{
T get();
}
表示结果的提供者
Consumer接口
public interface Consumer<T>{
void accept(T t);
}
带一个参数且不返回结果的操作
Q.E.D.