long sum= 0;
for(Long value : map.values()){
sum= sum+value;
}
先在将map转换为set 通过stream+lambda表达式转换为list ,使用lambda 表达式求和
System.out.println(endOffsetsSUm);
//先在将map转换为set 通过stream+lambda表达式转换为list
List<Long> endOffsetsToList = endOffsets.entrySet().stream().map(x -> x.getValue()).collect(Collectors.toList());
Long sum = endOffsetsToList.stream().mapToLong(x->x).sum();