Here you can find the source of asSet(K... values)
@SuppressWarnings("unchecked") public static final <K> HashSet<K> asSet(K... values)
//package com.java2s; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashSet; public class Main { @SuppressWarnings("unchecked") public static final <K> HashSet<K> asSet(K... values) { return new HashSet<K>(Arrays.asList(values)); }/*from w w w. j a va 2 s. c o m*/ /** * Creates a new {@link ArrayList} from a collection by building an * enumeration over the collection. */ public static final <K> ArrayList<K> asList(Collection<K> values) { return Collections.list(Collections.<K>enumeration(values)); } }