Java List Split split(final List list, final int count)

Here you can find the source of split(final List list, final int count)

Description

split

License

LGPL

Declaration

public static List split(final List list, final int count) 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import java.util.ArrayList;
import java.util.List;

public class Main {

    public static List split(final List list, final int count) {
        List subIdLists = new ArrayList();
        if (list.size() < count) {
            subIdLists.add(list);//  w ww .jav a  2  s  .c  om
        } else {
            int i = 0;
            while (i < list.size()) {
                int end = i + count;
                if (end > list.size()) {
                    end = list.size();
                }
                subIdLists.add(list.subList(i, end));
                i += count;
            }
        }
        return subIdLists;
    }
}

Related

  1. split(final List list, final int index)
  2. split(final List orginalList, final int splitSize)
  3. split(final List original, final int maxListSize, final Class listImplementation)
  4. split(final String line, final char delimiter, final List parts)