Here you can find the source of partitionList(List list, int folds)
public static List[] partitionList(List list, int folds)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { public static List[] partitionList(List list, int folds) { List[] partitions = new List[folds]; int partitionSize = list.size() / folds, index; for (int i = 0; i < folds; i++) { index = i * partitionSize;// w w w. j ava 2 s . co m partitions[i] = list.subList(index, i < folds - 1 ? index + partitionSize : list.size()); } // for return partitions; } }