I want to init a Map<String, BigDecimal> and want to always put the same BigDecimal value from outside of the stream.
BigDecimal samePrice;
Set<String> set;
set.stream().collect(Collectors.toMap(Function.identity(), samePrice));
However Java complains as follows:
The method toMap(Function, Function) in the type Collectors is not applicable for the arguments (Function, BigDecimal)
Why can't I use the BigDecimal from outside? If I write:
set.stream().collect(Collectors.toMap(Function.identity(), new BigDecimal()));
it would work, but that's of course not what I want.