Vic*_*cci 2 java lambda java-stream
我有一个二元函数:
public Integer binaryFunction(Integer a, Integer b){
//some stuff
}
Run Code Online (Sandbox Code Playgroud)
我有这个流:
Integer fixedValue = ...
List<Integer> otherValues = ...
otherValues.map(value -> binaryFunction(value, fixedValue)).collect(...);
Run Code Online (Sandbox Code Playgroud)
我想知道如何map(this::binaryFunction)在我的流中使用。我尝试过类似的方法,但它不起作用:
values.map(value -> (value, fixedValue)).map(this::binaryFunction).collect(...);
Run Code Online (Sandbox Code Playgroud)
但这不起作用。我正在寻找可以接受两个值的供应商。
注意:我不想更改binaryFunction声明。