import java.util.ArrayList;
import java.util.List;
public class Main {
public static List<List<Integer>> split(List<Integer> lst, int chunk) {
List<List<Integer>> result = new ArrayList<>();
for (int i = 0; i < lst.size(); i += chunk) {
result.add(lst.subList(i, Math.min(i + chunk, lst.size())));
}
return result;
}
public static void main(String[] args) {
List<Integer> aList = new ArrayList<>();
for (int i = 0; i < 32; i++) {
aList.add(i);
}
System.out.println(split(aList, 5));
}
}
/*
run:
[[0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19], [20, 21, 22, 23, 24], [25, 26, 27, 28, 29], [30, 31]]
*/