Java examples for java.util:HashSet
create HashSet from varargs
//package com.book2s; import java.util.Collection; import java.util.HashSet; public class Main { public static final <E> HashSet<E> createHashSet(E... elements) { HashSet<E> list = new HashSet<E>(); addToCollection(list, elements); return list; }//from ww w .j a v a2 s. c om public static final <E> void addToCollection( Collection<? super E> collection, E... elements) { for (E e : elements) { collection.add(e); } } }