Here you can find the source of splitArray(int[] array, int limit)
public static List<int[]> splitArray(int[] array, int limit)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Main { public static List<int[]> splitArray(int[] array, int limit) { List<int[]> list = new ArrayList<>(); if (array.length <= limit) { list.add(array);/*from w ww . j av a 2s. c om*/ return list; } int count = getSplitCount(array.length, limit); int copied = 0; for (int i = 0; i < count; i++) { list.add(Arrays.copyOfRange(array, copied, Math.min(array.length, copied + limit))); copied += limit; } return list; } public static int getSplitCount(int length, int maxlength) { int count = length / maxlength; if ((length % maxlength) != 0) { count++; } return count; } }