How to split array list into equal parts?

前端 未结 9 1284
攒了一身酷
攒了一身酷 2020-11-29 07:20

Is there anyway to split ArrayList into different parts without knowing size of it until runtime? I know there is a method called:

list.subList(a,b);
         


        
9条回答
  •  遥遥无期
    2020-11-29 08:05

    listSize = oldlist.size();
    chunksize =1000;
    chunks = list.size()/chunksize;
    ArrayList subLists;
    ArrayList finalList;
    int count = -1;
    for(int i=0;i

    You can use this finalList as it contains the list of chuncks of the oldList.

提交回复
热议问题