Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.*;

public class Main {
    public static <T> Set<T> immutableSet(T element) {
        Set<T> immutableSet = new HashSet<T>();
        immutableSet.add(element);
        return immutableSet(immutableSet);
    }

    public static <T> Set<T> immutableSet(Collection<? extends T> set) {
        return Collections.unmodifiableSet(set instanceof Set ? (Set<? extends T>) set : new HashSet<T>(set));
    }

    public static <T> Set<T> immutableSet(T... set) {
        if (set == null)
            return Collections.emptySet();
        return Collections.unmodifiableSet(new HashSet<T>(Arrays.asList(set)));
    }
}