list等长度切割
作者:互联网
/**
* 将list集合等分切割
*
* @param list
* @param number
* @return
*/
public <T> List<List<T>> cutList(List<Integer> list, int number) {
List<List<T>> lists = new ArrayList<>();
List<T> list1 = new ArrayList<>();
int count = 0;
for (Integer item : list) {
list1.add((T) item);
++count;
if (count % number == 0) {
lists.add(list1);
list1 = new ArrayList<>();
count = 0;
}
}
return lists;
}
标签:count,切割,list1,list,ArrayList,List,number,长度 来源: https://www.cnblogs.com/babystudy/p/16173517.html