Java java.util HashSet fields, constructors, methods, implement or subclass

Example usage for Java java.util HashSet fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for java.util HashSet.

The text is from its open source code.

Subclass

java.util.HashSet has subclasses.
Click this link to see all its subclasses.

Constructor

HashSet()
Constructs a new, empty set; the backing HashMap instance has default initial capacity (16) and load factor (0.75).
HashSet(Collection c)
Constructs a new set containing the elements in the specified collection.
HashSet(int initialCapacity)
Constructs a new, empty set; the backing HashMap instance has the specified initial capacity and default load factor (0.75).
HashSet(int initialCapacity, float loadFactor)
Constructs a new, empty set; the backing HashMap instance has the specified initial capacity and the specified load factor.

Method

booleanadd(E e)
Adds the specified element to this set if it is not already present.
booleanaddAll(Collection c)
Adds all of the elements in the specified collection to this set if they're not already present (optional operation).
voidclear()
Removes all of the elements from this set.
Objectclone()
Returns a shallow copy of this HashSet instance: the elements themselves are not cloned.
booleancontains(Object o)
Returns true if this set contains the specified element.
booleancontainsAll(Collection c)
Returns true if this set contains all of the elements of the specified collection.
booleanequals(Object o)
Compares the specified object with this set for equality.
voidforEach(Consumer action)
Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception.
inthashCode()
Returns the hash code value for this set.
booleanisEmpty()
Returns true if this set contains no elements.
Iteratoriterator()
Returns an iterator over the elements in this set.
StreamparallelStream()
Returns a possibly parallel Stream with this collection as its source.
booleanremove(Object o)
Removes the specified element from this set if it is present.
booleanremoveAll(Collection c)
Removes from this set all of its elements that are contained in the specified collection (optional operation).
booleanremoveIf(Predicate filter)
Removes all of the elements of this collection that satisfy the given predicate.
booleanretainAll(Collection c)
Retains only the elements in this set that are contained in the specified collection (optional operation).
intsize()
Returns the number of elements in this set (its cardinality).
Streamstream()
Returns a sequential Stream with this collection as its source.
Object[]toArray()
Returns an array containing all of the elements in this set.
T[]toArray(T[] a)
Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array.
StringtoString()
Returns a string representation of the object.