Java HashSet Create hashSet()

Here you can find the source of hashSet()

Description

hash Set

License

Open Source License

Parameter

Parameter Description
O Object type

Return

HashSet

Declaration

public static <O> HashSet<O> hashSet() 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.Collections;
import java.util.HashSet;

public class Main {
    /**/*from   w  w w .j  a v a2  s.  c om*/
     *
     * @param <O> Object type
     * @return HashSet
     */
    public static <O> HashSet<O> hashSet() {
        return new HashSet<>();
    }

    /**
     *
     * @param <O> Object type
     * @param objects Zero to many objects
     * @return HashSet of given objects
     */
    @SafeVarargs
    public static <O> HashSet<O> hashSet(O... objects) {
        HashSet<O> hashSet = hashSet();

        if (objects != null) {
            Collections.addAll(hashSet, objects);
        }

        return hashSet;
    }
}

Related

  1. asHashSet(Set set)
  2. asHashSet(T... elements)
  3. convertHashSetIntoArray(HashSet cdsidsSet)
  4. createHashSet(T... arr)
  5. hashSet()
  6. hashset_to_int_array(Set hs)
  7. hashSetFromArray(final T[] objs)
  8. hashSetOf(T... elements)
  9. hashSetOf(T... ts)