Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Collection;

import java.util.concurrent.CopyOnWriteArrayList;

public class Main {
    /**
     * Create a {@link CopyOnWriteArrayList} with zero or more "objects".
     * @param <O>
     * @return CopyOnWriteArrayList<O>
     */
    @SafeVarargs
    public static <O> CopyOnWriteArrayList<O> copyOnWriteArrayList(O... objects) {
        CopyOnWriteArrayList<O> list = new CopyOnWriteArrayList<>();

        for (O object : objects) {
            list.add(object);
        }

        return list;
    }

    /**
     * Create a {@link CopyOnWriteArrayList} from a given {@link Collection}
     * @param source
     * @return CopyOnWriteArrayList<O>
     */
    public static <O> CopyOnWriteArrayList<O> copyOnWriteArrayList(Collection<O> source) {
        return new CopyOnWriteArrayList<>(source);
    }
}