Here you can find the source of partition(List
public static List<List<Long>> partition(List<Long> all, int partitionSize)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; public class Main { public static List<List<Long>> partition(List<Long> all, int partitionSize) { List<List<Long>> partitions = new ArrayList<>(); final int count = all.size(); for (int i = 0; i < count; i += partitionSize) { partitions.add(new ArrayList<>(all.subList(i, Math.min(count, i + partitionSize)))); }/*from ww w.j a v a2s .c o m*/ return partitions; } }