Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Underlying DataStructure for HashSet [closed]

Tags:

java

For ArrayList underlying dataStructure is Array, for LinkedList it is Link object and for HashMap or HashTable it can be an Array Of LinkedList or Tree, what is the datastructure used in HashSet

like image 626
Ullas Avatar asked Dec 12 '22 13:12

Ullas


1 Answers

According to the Javadoc the backing data structure for a HashSet is a HashMap.

The JDK 1.6 code verifies this:

public HashSet() {
    map = new HashMap<>();
}
like image 108
lreeder Avatar answered Jan 02 '23 18:01

lreeder