Here you can find the source of split(List
public static <T> List<List<T>> split(List<T> list, int size)
//package com.java2s; import java.util.*; public class Main { public static <T> List<List<T>> split(List<T> list, int size) { List<List<T>> result = new ArrayList<>(); int n = list.size() / size; int r = list.size() % size; for (int i = 0; i < n; i++) { List<T> split = new ArrayList<>(); for (int j = i * size; j < i * size + size; j++) { split.add(list.get(j));//from www . j a v a 2 s.c o m } result.add(split); } if (r > 0) { List<T> rest = new ArrayList<>(); for (int i = n * size; i < list.size(); i++) { rest.add(list.get(i)); } result.add(rest); } return result; } }