Hashtable

Hashtable is an implementation for storing/processing list of objects using a hashkey and buckets.

Hashtable has default load capacity of 11, where it will create default 11 buckets if not provided in specific., and stores the list of objects in the buckets based on the object hashkey.

Any object/value inserted into Hashtable object, will be checked for its hashCode using the hashCode() method, and based on the hashCode, the value/object is inserted into the corresponding bucket.

If more then one values/objects has the same bucket, then the values/objects will follow a Linked list pattern of storing their values in the bucket.

  • HashTable is Synchronized in Implementation of all methods, hence it is threadsafe.,
  • HashTable Class has a private class & Object Entry, which stores key and values based on the hashCode., acts as the bucket.
  • HashTable class loads with the default capacity of 11.
  • Everytime when the bucket is full and more values are added, based on the load factor value, (default is 0.75%), the bucket will be increased, to fit more values dynamically inside the HashTable., called as Rehashing.

HashTable is an effective implementation in which hashing logic acts as a base for new data structure libraries like HashSet, HashMap etc., in searching/retrieval of a object in a list in a effective way.,

Result:

Leave a Reply

Your email address will not be published. Required fields are marked *