/**
* 通过list的 subList(int fromIndex, int toIndex)方法实现
* @param sourList 源list
* @param batchCount 分组条数
*/
public static void dealBySubList(List<Object> sourList, int batchCount){
int sourListSize = sourList.size();
int subCount = sourListSize%batchCount==0 ? sourListSize/batchCount : sourListSize/batchCount+1;
int startIndext = 0;
int stopIndext = 0;
for(int i=0;i<subCount;i++){
stopIndext = (i==subCount-1) ? stopIndext + sourListSize%batchCount : stopIndext + batchCount;
List<Object> tempList = new ArrayList<Object>(sourList.subList(startIndext, stopIndext));
printList(tempList);
startIndext = stopIndext;
}
}
————————————————
版权声明:本文为CSDN博主「hunheidaode」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/hunheidaode/article/details/100098077
网友评论