List
<Title> list
= .....
list
.stream().mapToInt(s
-> Integer
.valueOf(s
.getScore())).sum();
避开null,数据库中存的字符串,列表中需转成数字并汇总
int sum
= list
.stream().collect(Collectors
.summingInt(f
->f
.getScore()==null
?0:Integer
.valueOf(f
.getScore())));
转载请注明原文地址: https://lol.8miu.com/read-28336.html