Here you can find the source of zip(final List
Parameter | Description |
---|---|
Element | type used in the list |
l1 | first list, merged at uneven positions |
l2 | second list, merged at even positions |
public static <Element> List<Element> zip(final List<Element> l1, final List<Element> l2)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; public class Main { /**/*from w w w .j a v a 2s . co m*/ * Zips 2 lists together. * @param <Element> type used in the list * @param l1 first list, merged at uneven positions * @param l2 second list, merged at even positions * @return zipped list */ public static <Element> List<Element> zip(final List<Element> l1, final List<Element> l2) { ArrayList<Element> result = new ArrayList<Element>(); for (int i = 0; i < l1.size(); i++) { result.add(l1.get(i)); result.add(l2.get(i)); } return result; } }