Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//it under the terms of the GNU Affero General Public License as published by

import java.util.ArrayList;

import java.util.LinkedList;
import java.util.List;

public class Main {
    public static <T> List<List<T>> splitEvery(Iterable<T> input, int size) {
        List<List<T>> listOfList = new LinkedList<List<T>>();
        List<T> list = null;
        int index = 0;
        for (T t : input) {
            if ((index % size) == 0) {
                list = new ArrayList<T>(size);
                listOfList.add(list);
            }
            index++;
            list.add(t);
        }
        return listOfList;
    }
}