The Stream.reduce method takes a BinaryOperator as an argument. The function signature of a BinaryOperator is (T,T) -> T. The BigDecimal::min method has only 1 parameter in its method signature (ie. (T) -> T ).
Why doesn't the compiler complain when I pass BigDecimal::min to the Stream.reduce method?
Sample code:
List<BigDecimal> bigDecimalList = new ArrayList<>();
bigDecimalList.add(BigDecimal.valueOf(1));
bigDecimalList.add(BigDecimal.valueOf(2));
bigDecimalList.add(BigDecimal.valueOf(3));
BigDecimal minResult = bigDecimalList.stream().reduce(BigDecimal::min).orElse(BigDecimal.ZERO);
Thanks.