Java List Zip zip(List> lists)

Here you can find the source of zip(List> lists)

Description

zip

License

Apache License

Declaration

public static <T> List<List<T>> zip(List<List<T>> lists) 

Method Source Code


//package com.java2s;
//    Licensed under the Apache License, Version 2.0 (the "License");

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

public class Main {
    public static <T> List<List<T>> zip(List<List<T>> lists) {
        List<List<T>> zipped = new ArrayList<List<T>>();
        for (List<T> list : lists) {
            for (int i = 0, listSize = list.size(); i < listSize; i++) {
                List<T> zipList;
                if (i >= zipped.size()) {
                    zipped.add(zipList = new ArrayList<T>());
                } else {
                    zipList = zipped.get(i);
                }//w  w w.  j  a  v  a  2s.  c om
                zipList.add(list.get(i));
            }
        }
        return zipped;
    }
}

Related

  1. zip(final List l1, final List l2)
  2. zip(List a, List b)
  3. zip(List> lists)
  4. zipDoubleArray(List lists)
  5. zipper(List> listOfLists)