Here you can find the source of mergeArrayIntoCollection(T[] array, Collection
Parameter | Description |
---|---|
T | type of elements of array |
array | the array to merge (may be <code>null</code>) |
collection | the target Collection to merge the array into |
public static <T> void mergeArrayIntoCollection(T[] array, Collection<T> collection)
//package com.java2s; /******************************************************************************* * Copyright (c) 2008, 2010 VMware Inc.// w w w.ja v a 2s.co m * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * VMware Inc. - initial contribution *******************************************************************************/ import java.util.Collection; public class Main { /** * Merge the given array into the given Collection. * @param <T> type of elements of array * @param array the array to merge (may be <code>null</code>) * @param collection the target Collection to merge the array into */ public static <T> void mergeArrayIntoCollection(T[] array, Collection<T> collection) { if (collection == null) { throw new IllegalArgumentException("Collection must not be null"); } for (int i = 0; i < array.length; i++) { collection.add(array[i]); } } }