Here you can find the source of addAll(int index, List
Parameter | Description |
---|---|
T | a parameter |
index | a parameter |
list | a parameter |
array | a parameter |
public static <T> List<T> addAll(int index, List<T> list, T... array)
//package com.java2s; /*//from w ww. j a v a2 s . c o m * Copyright (C) 2016 Timo Vesalainen <timo.vesalainen@iki.fi> * * This program 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. * * This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */ import java.util.Collection; import java.util.List; public class Main { /** * Adds array members to list * @param <T> * @param list * @param array */ public static <T> Collection<T> addAll(Collection<T> list, T... array) { for (T item : array) { list.add(item); } return list; } /** * Add arrays members to list starting at index. * <p> * If list contains a,b,c,d and array 1,2,3. After addAll(2, list, array) * list contains a,b,1,2,3,c,d * @param <T> * @param index * @param list * @param array */ public static <T> List<T> addAll(int index, List<T> list, T... array) { for (T item : array) { list.add(index++, item); } return list; } }