Java Utililty Methods List Split

List of utility methods to do List Split

Description

The list of methods to do List Split are organized into topic(s).

Method

List>split(List list, final int parts)
split
List<List<T>> subLists = new ArrayList<>(parts);
for (int i = 0; i < parts; i++) {
    subLists.add(new ArrayList<T>());
for (int i = 0; i < list.size(); i++) {
    subLists.get(i % parts).add(list.get(i));
return subLists;
...
List>split(List list, int size)
Splits the list.
if (list == null) {
    throw new NullPointerException("The list parameter is null.");
if (size <= 0) {
    throw new IllegalArgumentException("The size parameter must be more than 0.");
int num = list.size() / size;
int mod = list.size() % size;
...
List>split(List list, int size)
split
List<List<T>> lists = new ArrayList<List<T>>();
int count = (list.size() / size) + (list.size() % size == 0 ? 0 : 1);
for (int i = 0; i < count; i++) {
    int fromIndex = i * size, toIndex = (i + 1) * size;
    List<T> subList = list.subList(fromIndex, toIndex > list.size() ? list.size() : toIndex);
    lists.add(subList);
return lists;
...
List>split(List list, int size)
split
List<List<T>> result = new ArrayList<>();
int n = list.size() / size;
int r = list.size() % size;
for (int i = 0; i < n; i++) {
    List<T> split = new ArrayList<>();
    for (int j = i * size; j < i * size + size; j++) {
        split.add(list.get(j));
    result.add(split);
if (r > 0) {
    List<T> rest = new ArrayList<>();
    for (int i = n * size; i < list.size(); i++) {
        rest.add(list.get(i));
    result.add(rest);
return result;
List>split(List list, int size)
Splits a List into a list of smaller lists within the maximum size.
if (size == 0) {
    throw new IllegalArgumentException("List size must be > 0");
List<List<T>> lists = new ArrayList<List<T>>();
for (int i = 0; i < list.size(); i += size) {
    lists.add(list.subList(i, Math.min(i + size, list.size())));
return lists;
...
List>split(List list, int splitSize)
split
if (list == null || list.isEmpty() || splitSize <= 0) {
    return Collections.emptyList();
List<List<T>> result = new ArrayList<List<T>>();
if (list.size() > splitSize) {
    int fromIndex = 0;
    while (true) {
        int toIndex = fromIndex + splitSize;
...
List>split(List lst)
Split list in two.
List<List<T>> tmp = new ArrayList<>();
int N = lst.size();
tmp.add(new ArrayList<>(lst.subList(0, N / 2)));
tmp.add(new ArrayList<>(lst.subList(N / 2, N)));
return tmp;
List>split(List toSplit, int howOften)
This does something with splitting things.
List<List<T>> list = new ArrayList<List<T>>(howOften);
for (int i = 0; i < howOften; i++) {
    list.add(new ArrayList<T>());
int i = 0;
for (T t : toSplit) {
    list.get(i).add(t);
    i = (i + 1) % howOften;
...
ArrayList>split(List list, int divide)
split
int remain = list.size() % divide;
int size = (list.size() - remain) / divide;
ArrayList<List<V>> toReturn = new ArrayList<List<V>>();
for (int i = 0; i < divide; i++) {
    toReturn.add(i, new ArrayList<V>());
for (List<V> iterSet : toReturn) {
    List<V> removed = new ArrayList<V>();
...
List>splitList(List files, int limit)
split List
List<List<String>> result = new ArrayList<List<String>>();
int top = files.size();
int start = 0;
while (start < top) {
    int max = Math.min(limit, top - start);
    result.add(files.subList(start, start + max));
    start += max;
return result;