List<CommonExportDTO> commonList;
// 取字段string轉int構建新列表
List<Integer> collect = commonList.stream().map(dto -> Integer.valueOf(dto.getCell6())).collect(Collectors.toList());
// reduce求和 Optional<Integer> reduce = collect.stream().reduce(Integer::sum); Integer total = reduce.get();
參考地址
JDK 1.8 新特性之Stream 詳解個人筆記:https://blog.csdn.net/chenhao_c_h/article/details/80691284
實現一個LIST集合中的某個元素的求和: https://www.cnblogs.com/jishumonkey/p/12166541.html
Java8對List<Integer>的求和:https://blog.csdn.net/hsz2568952354/article/details/89886743