Here you can find the source of hashSet()
Parameter | Description |
---|---|
O | Object type |
public static <O> HashSet<O> hashSet()
//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; } }