将一个集合list等分成几个集合

来源:互联网 发布:成本管理数据分析 编辑:程序博客网 时间:2024/05/17 02:59
int pageSize = 4;int total = splist.size();int pageCount = total % pageSize == 0 ? total / pageSize : total / pageSize + 1;for(int i = 0; i < pageCount; i++) {Map<Integer,List<MxxzWebsitComment>> tmpMap =new HashMap();int start = i * pageSize;int end = start + pageSize > total ? total : start + pageSize;List<MxxzWebsitComment> subList = splist.subList(start, end);tmpMap.put(i, subList);tmpList.add(tmpMap);}

0 0