Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.util.Collection;

import java.util.HashSet;

import java.util.Set;
import java.util.Arrays;

public class Main {
    /**
     * Get a new set
     * @param <T>
     * @return Set
     */
    public static <T> Set<T> set() {
        return new HashSet<T>();
    }

    /**
     * Get a new set with the elements
     * @param elements T
     * @param <T>
     * @return Set
     */
    @SuppressWarnings("unchecked")
    public static <T> Set<T> set(final T... elements) {
        return set(Arrays.asList(elements));
    }

    /**
     * Get a new set
     * @param tCollection {@link Collection}
     * @param <T>
     * @return Set
     */
    public static <T> Set<T> set(final Collection<T> tCollection) {
        return new HashSet<T>(tCollection);
    }
}