Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2008, 2010 VMware Inc.
 * 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]);
        }
    }
}