集册 Java实例教程 将一些Iterable连接到一个。

将一些Iterable连接到一个。

欢马劈雪     最近更新时间:2020-01-02 10:19:05

339
将一些Iterable s连接到单个Iterable s。
/*nowjava 提 供*/

import java.util.ArrayList;

import java.util.Collection;

import java.util.Collections;

import java.util.Iterator;

import java.util.List;


public class Main{

    /**

     * Joins some {@link Iterable}s to a single one.

     *

     * @param iterables

     *          A set of {@link Iterable}s to join to a single {@link Iterable}.<br>

     *          May contain <code>null</code>s.

     * @return A single {@link Iterable}. Never <code>null.</code>

     */

    @SuppressWarnings("unchecked")

    public static <T> Iterable<T> join(Iterable<? extends T>... iterables) {

        if (iterables.length == 0) {

            return Collections.emptyList();

        }

        if (iterables.lengt
展开阅读全文