Java tutorial
//package com.java2s; import java.util.ArrayList; import java.util.List; public class Main { public static <O> List<List<O>> split(List<O> l, int targetSize) { List<List<O>> groups = new ArrayList<List<O>>(); for (int i = 0; i < l.size(); i += targetSize) { groups.add(l.subList(i, Math.min(i + targetSize, l.size()))); } return groups; } }