Here you can find the source of merge(T[]... arrays)
Parameter | Description |
---|---|
arrays | set of arrays to combine into a list |
T | type of object included in the set of arrays |
public static <T> List<T> merge(T[]... arrays)
//package com.java2s; /*// ww w.j ava 2 s. co m * This file is part of Commodus. * * Commodus is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Commodus is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Commodus. If not, see <http://www.gnu.org/licenses/>. */ import java.util.*; public class Main { /** * Merges a set of arrays into a single list, maintaining original order * * @param arrays set of arrays to combine into a list * @param <T> type of object included in the set of arrays * @return a combined list including all original objects in the given arrays */ public static <T> List<T> merge(T[]... arrays) { ArrayList<T> merged = new ArrayList<>(); for (T[] array : arrays) { Collections.addAll(merged, array); } return merged; } }