Java Set Create asSet(K... values)

Here you can find the source of asSet(K... values)

Description

as Set

License

Open Source License

Declaration

@SuppressWarnings("unchecked")
    public static final <K> HashSet<K> asSet(K... values) 

Method Source Code

//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));
    }
}

Related

  1. asSet(final E... elements)
  2. asSet(final T t, final T... ts)
  3. asSet(final T... array)
  4. asSet(int... values)
  5. asSet(Iterable iteratable)
  6. asSet(Object[] array)
  7. asSet(Optional opt)
  8. asSet(T... a)
  9. asSet(T... a)