Create new Hash Set - Java java.util

Java examples for java.util:Set Creation

Description

Create new Hash Set

Demo Code


//package com.java2s;

import java.util.Collection;

import java.util.HashSet;

public class Main {
    public static void main(String[] argv) {
        System.out.println(newHashSet());
    }//from  www . j a  v  a 2s.com

    public static <E> HashSet<E> newHashSet() {
        return new HashSet<E>();
    }

    public static <E> HashSet<E> newHashSet(final Collection<? extends E> c) {
        return new HashSet<E>(c);
    }

    public static <E> HashSet<E> newHashSet(final int initialCapacity) {
        return new HashSet<E>(initialCapacity);
    }

    public static <E> HashSet<E> newHashSet(final int initialCapacity,
            final float loadFactor) {
        return new HashSet<E>(initialCapacity, loadFactor);
    }
}

Related Tutorials