Java tutorial
//package com.java2s; import java.util.HashSet; import java.util.Set; public class Main { /** * Returns a new Set containing the given values */ public static <T> Set<T> setOf(T... values) { Set<T> set = newHashSet(); for (T value : values) set.add(value); return set; } /** * Returns a new empty HashSet for objects of a certain type */ public static <T> HashSet<T> newHashSet() { return new HashSet<T>(); } }