About HashTable in Java

What’s HashMap

HashTable is a data structure used to implement an associative array, a structure that can map keys to values. A hash table uses a hash function to compute an index into an array.

Hash table - Wikipedia

Structure Of HashMap in Java

HashMap class in java has array internally to save objects. The objects are Nodes that have key and value.


Hash Function

HashMap has a Hash Function. This function computes the index from inputted key.

Hash Collision

HashTable has a problem. When it computes the index by hash function, the results value of hash function can be identical. This phenomenon is called as Collision. In java, if collision occurs, the object is linked with a node has same index. Therefore, each node in array has Binary Search Tree.