【发布时间】:2020-03-26 04:57:54
【问题描述】:
我正在尝试使用以下代码使用reduce函数来组合函数:
class CustomClass {
private Function<Map<String, String>, Integer> cal;
public CustomClass (Function<Map<String, String>, Integer>... func) {
cal = Stream.of(func)
.reduce(Function.identity(), Function::andThen);
}
}
但我收到此错误:
The method reduce(Function<Map<String,String>,Integer>, BinaryOperator<Function<Map<String,String>,Integer>>)
in the type Stream<Function<Map<String,String>,Integer>> is not applicable
for the arguments (Function<Object,Object>, Function::andThen)
我在这里做错了什么?
【问题讨论】: