java list分组 list里面分装的都是对象 按照对象的属性来分组

mac2022-06-30  22

http://www.iteye.com/problems/86110

——————————————————————————————————————————————————————————

List<Bill> list = billFacade.findBillByUserId(userInfo); Map<String, Float> group = new HashMap<String, Float>(); String type = null; Float moneyTotal = 0f; for(Bill bill : list){ type = bill.getType(); moneyTotal = group.get(type); if(moneyTotal == null){ moneyTotal = 0f; } group.put(type, moneyTotal + bill.getMoney()); }

 

转载于:https://www.cnblogs.com/cuizhf/p/4329301.html

最新回复(0)