Java tutorial
//package com.java2s; // Use of this source code is governed by a BSD-style license that can be import java.util.Collections; import java.util.HashSet; public class Main { public static <E> HashSet<E> newHashSet(E... elements) { HashSet<E> set = new HashSet<E>(elements.length); Collections.addAll(set, elements); return set; } }