java简单代码:list转map

list 转成map:
List fList = queryService.getXXXList();
   List lst = null;
   Cfile cf = null;
   if (fList != null && fList.size() > 0) {
    for (int i = 0; i < fList.size(); i++) {
     cf = (Cfile) fList.get(i);
     String key = cf.getxxx();
     if (fileMap.get(key) != null) {
      lst = (List) fileMap.get(key);
     } else {
      lst = new ArrayList();
     }
     lst.add(cf);
     fileMap.put(key, lst);
    }
   }
/////////////////////////list 排序(内部类形式)/////////////////////////////////
Collections.sort(list, new Comparator(){
public int compare(Object arg0, Object arg1) {
InformBaseInfoVO ibiv0 = (InformBaseInfoVO)arg0;
InformBaseInfoVO ibiv1 = (InformBaseInfoVO)arg1;
return ibiv0.getNoticeDate().compareTo(ibiv1.getNoticeDate());
}
});
Collections.reverse(list);//倒序
///////////////////////////////////////////////

你可能感兴趣的:(java,list,转换,map)