Java List Partition partition(List list, int size)

Here you can find the source of partition(List list, int size)

Description

partition

License

Open Source License

Declaration

final public static <T> List<List<T>> partition(List<T> list, int size) 

Method Source Code

//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;
    }
}

Related

  1. partition(List items, int slices)
  2. partition(List list, int num)
  3. partition(List list, int partitionSize)
  4. partition(List list, int size)
  5. partition(List list, int size)
  6. partition(List longList, int length)
  7. partition(List orig, int size)
  8. partition(List sourceList, int numberOfSegments)
  9. partitionIntoFolds( List values, int numFolds)