示例Map>的inputMap:{"product":["132377","2123232","312335678","423432","5215566"],"order":["3174252","1468453","1264543","35723112","235775645"]}
1、使用forEach实现Map resultSet = new HashMap<>();
inputMap.forEach((k, v) -> resultSet.put(k, v.stream()
.mapToDouble(s -> computeScore(s)).sum()));
2、使用collect()实现Map finalResult = inputMap.entrySet()
.stream()
.collect(Collectors.toMap(
Entry::getKey,
e -> e.getValue()
.stream()
.mapToDouble(str -> computeScore(str))
.sum()));
或Map finalResult = inputMap.entrySet()
.stream()
.map(entry -> new AbstractMap.SimpleEntry( // maps each key to a new
// Entry
entry.getKey(), // the same key
entry.getValue().stream()
.mapToDou