🌐
Oracle
docs.oracle.com › en › java › javase › 17 › docs › api › java.base › java › util › HashSet.html
HashSet (Java SE 17 & JDK 17)
April 21, 2026 - This class offers constant time performance for the basic operations (add, remove, contains and size), assuming the hash function disperses the elements properly among the buckets. Iterating over this set requires time proportional to the sum of the HashSet instance's size (the number of elements) plus the "capacity" of the backing HashMap instance (the number of buckets).
🌐
GitHub
github.com › openjdk › jdk › blob › master › src › java.base › share › classes › java › util › HashSet.java
jdk/src/java.base/share/classes/java/util/HashSet.java at master · openjdk/jdk
@java.io.Serial · static final long serialVersionUID = -5024744406713321676L; · transient HashMap<E,Object> map; · // Dummy value to associate with an Object in the backing Map · static final Object PRESENT = new Object(); · /** * Constructs a new, empty set; the backing {@code HashMap} instance has · * default initial capacity (16) and load factor (0.75). */ public HashSet() { map = new HashMap<>(); } ·
Author   openjdk
🌐
Oracle
docs.oracle.com › en › java › javase › 21 › docs › api › java.base › java › util › HashSet.html
HashSet (Java SE 21 & JDK 21)
January 20, 2026 - To create a HashSet with an initial capacity that accommodates an expected number of elements, use newHashSet.
🌐
Oracle
docs.oracle.com › en › java › javase › 17 › docs › api › java.base › java › util › class-use › HashSet.html
Uses of Class java.util.HashSet (Java SE 17 & JDK 17)
January 20, 2026 - Package javax.print.attribute.standard contains classes for specific printing attributes. ... Hash table and linked list implementation of the Set interface, with predictable iteration order. Subclasses of HashSet in javax.print.attribute.standard
🌐
Oracle
docs.oracle.com › en › java › javase › 17 › docs › api › java.base › java › util › Set.html
Set (Java SE 17 & JDK 17)
April 21, 2026 - Package java.util · Type Parameters: E - the type of elements maintained by this set · All Superinterfaces: Collection<E>, Iterable<E> All Known Subinterfaces: EventSet, NavigableSet<E>, SortedSet<E> All Known Implementing Classes: AbstractSet, ConcurrentHashMap.KeySetView, ConcurrentSkipListSet, CopyOnWriteArraySet, EnumSet, HashSet, JobStateReasons, LinkedHashSet, TreeSet ·
🌐
Oracle
docs.oracle.com › en › java › javase › 18 › docs › api › java.base › java › util › HashSet.html
HashSet (Java SE 18 & JDK 18)
August 18, 2022 - This class offers constant time performance for the basic operations (add, remove, contains and size), assuming the hash function disperses the elements properly among the buckets. Iterating over this set requires time proportional to the sum of the HashSet instance's size (the number of elements) plus the "capacity" of the backing HashMap instance (the number of buckets).
🌐
Oracle
docs.oracle.com › en › java › javase › 17 › docs › api › java.base › java › util › LinkedHashSet.html
LinkedHashSet (Java SE 17 & JDK 17)
January 20, 2026 - This class provides all of the optional Set operations, and permits null elements. Like HashSet, it provides constant-time performance for the basic operations (add, contains and remove), assuming the hash function disperses elements properly among the buckets.
🌐
GeeksforGeeks
geeksforgeeks.org › java › hashset-in-java
HashSet in Java - GeeksforGeeks
Capacity refers to the number of buckets in the hash table. The default capacity of a HashSet is 16 and the load factor is 0.75.
Published   April 24, 2026
Find elsewhere
🌐
CodeSignal
codesignal.com › learn › courses › hashing-dictionaries-and-sets-in-java › lessons › mastering-java-hashset-an-in-depth-exploration-of-implementation-and-complexity-analysis
Mastering Java HashSet: An In-depth Exploration of ...
Under its hood, a HashSet uses a hash table to manage all its elements. A hash table revolves around an array of buckets that store all items. A hash function is integrated to generate a hash code; the hashed key indicates the memory location where each element gets stored, accelerating the element storage and retrieval process. In Java, the add(), remove(), and contains() operations in the HashSet class rely on the hash code of the object you're dealing with.
🌐
Medium
rameshfadatare.medium.com › java-hashset-691f9c5337de
Java HashSet. Welcome to the Java Collections… | by Ramesh Fadatare | Medium
September 19, 2024 - HashSet in Java is a part of the Java Collections Framework and implements the Set interface. It is a collection that uses a hash table for storage. Unlike List, a Set does not allow duplicate elements.
🌐
Android Developers
developer.android.com › api reference › hashset
HashSet | API reference | Android Developers
Skip to main content · English · Deutsch · Español – América Latina · Français · Indonesia · Polski · Português – Brasil · Tiếng Việt · 中文 – 简体
🌐
Upgrad
upgrad.com › home › tutorials › software & tech › hashset in java
HashSet in Java - A Complete Guide | upGrad
March 4, 2025 - The HashSet class implements the Set interface, it uses hashtable to store the elements and contains only unique elements.
🌐
Classpath
developer.classpath.org › doc › java › util › HashSet-source.html
Source for java.util.HashSet (GNU Classpath 0.95 Documentation)
116: * 117: * @param initialCapacity the initial capacity of the backing HashMap 118: * @param loadFactor the load factor of the backing HashMap 119: * @throws IllegalArgumentException if either argument is negative, or 120: * if loadFactor is POSITIVE_INFINITY or NaN 121: */ 122: public HashSet(int initialCapacity, float loadFactor) 123: { 124: map = init(initialCapacity, loadFactor); 125: } 126: 127: /** 128: * Construct a new HashSet with the same elements as are in the supplied 129: * collection (eliminating any duplicates, of course).