Here you can find the source of newHashSet(E... elements)
public static <E> HashSet<E> newHashSet(E... elements)
//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; }//from www .ja v a 2 s.co m }