How to split a string array into small chunk arrays in java?

前端 未结 12 1961
春和景丽
春和景丽 2020-12-05 05:15

Below is the example of the code snippet which needs the help

Example:

[1,2,3,4,5]
  • if the chunk size is 1,
12条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-05 05:39

    Easy way to do so,

        int loopcount = employeeList.size() / constCount;
        int leftcount = employeeList.size() % constCount;
        for (int i = 0; i < loopcount - 1; i++) {
            //query.setParameterList("values"+i, employeeList.subList(tempCount, tempCount + constCount));
    
            System.out.println(employeeList.subList(tempCount, tempCount + constCount));
            tempCount = tempCount + 1000;
        }
    

提交回复
热议问题