Here you can find the source of partition(List
final public static <T> List<List<T>> partition(List<T> list, int size)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; public class Main { final public static <T> List<List<T>> partition(List<T> list, int size) { List<List<T>> result = new ArrayList<List<T>>(list.size() / size); for (int i = 0; i < list.size(); i += size) { if (i + size < list.size()) result.add(list.subList(i, i + size)); else//from w w w .ja v a 2 s .co m result.add(list.subList(i, list.size())); } return result; } }