HashTable in Java is a type of Collections framework which is used to store and manipulate the group of objects. It is an array of the list in java (known as a bucket) which is used to implement a hash table, which maps keys to values. Hashtable contains unique elements. The initial default capacity of the Hashtable class is 11and doesn’t allow null keys and values.

HashTable in Java

Java Hashtable class implements the hashtable, which maps keys to the values. It inherits the  Dictionary class and implements the  Map interface. If we want to store and retrieve objects from a hashtable successfully, the objects used as keys must implement a hashCode method and the equals method.

  1. It is similar to the  HashMap, but it is synchronized.
  2. Hashtable stores key/value pair in the hash table.
  3. In the Hashtable, we specify the  object that is used as a key, and the value we want to associate to that key. The key is then hashed, and it resulting the hash code is used as an index at which a value is stored within the table.

#java #hashtable #hashmap

HashTable in Java Example | Java HashTable Tutorial
3.10 GEEK