java 复杂List对其中某一项求和
1、List<Double>
1 List<Double> dMoneyList = objList.stream().map(e->e.getDTotalMoney()/*复杂List中包含的double数值*/).collect(Collectors.toList());
2 Double totalmoneye = dMoneyList.stream().mapToDouble(val -> val).sum();
2、List<String>//纯数字字符串
1 List<String> timesList = objList.stream().map(e->e.getStrCouponTime()/*复杂List其中的纯数字字符串*/).collect(Collectors.toList()); 2 long sum = timesList.stream().mapToLong(Long::parseLong).sum(); 3 String strTotalTime = Long.toString(sum);