首页 > 代码库 > Map转化为List

Map转化为List

 List<JfAuction> jfAuctionListValue=http://www.mamicode.com/null; if(jfAuctionList!=null && jfAuctionList.size()>0){ Map jfAuctionMap = new HashMap(); for(JfAuction jfAuction:jfAuctionList){ if (jfAuctionMap.get(jfAuction.getUser().getId()) == null) { // 如果没有此类型,则添加此类型的数值 jfAuctionMap.put(jfAuction.getUser().getId(), jfAuction); }else{ // 如果有此类型,则把此类型的数值修改为-->原来的数值+新数值,实现类似sum功能 Integer sum=jfAuction.getScore()+jfAuctionMap.get(jfAuction.getUser().getId()).getScore(); jfAuction.setScore(sum); jfAuctionMap.put(jfAuction.getUser().getId(), jfAuction); } }

                }

Map转化为List