Java tutorial
//package com.java2s; import java.util.ArrayList; import java.util.List; public class Main { public static <T> List<List<T>> splitList(List<T> srcList, int maxSize) { List<List<T>> splitList = new ArrayList<List<T>>(); if (srcList == null || srcList.size() == 0) { return splitList; } int listSize = srcList.size(); int splitListSize = (listSize / maxSize) + (listSize % maxSize > 0 ? 1 : 0); for (int i = 0; i < splitListSize; i++) { int beginIndex = i * maxSize; int endIndex = (i + 1) * maxSize; endIndex = endIndex > listSize ? listSize : endIndex; splitList.add(srcList.subList(beginIndex, endIndex)); } return splitList; } }