HashTable in Java


Prev Tutorial Next Tutorial

HashTable in Java

HashTable is Implementer class of Map interface and extends Dictionary class. HashTable does not allows null key and null values, these elements will be stored in a random order.

Points to Remember

  • HashTable is a legacy class, which will uses hashing technique (the elements will be stored in unsorted or un-order format).
  • HashTable stored the elements in key values formate.
  • HashTable does not allows null keys and null values.
  • HashTable is Synchronized.
  • HashTable allows heterogeneous elements.
  • For retrieve elements from HashTable you can use foreach loop, Iterator Interface and Enumeration.

Note: HashTable class also contains same methods like HashMap.

Difference between HashMap and HashTable

1HashMap is a new class in java API.HashTable is a legacy class in java API.
2HashMap is not Synchronized.HashTable is Synchronized.
3HashMap allows maximum one null key and multiple null value.HashTable does not allows any null key and null values.

Limitations of HashTable

  • Hashtable class object is enable to read the data from property file / resource bundle file.
  • Hashtable class object is unable to develop flexible application.

Example of HashTable

import java.util.*;
class HashTableDemo
public static void main(String args[])
  HashTable<Integer,String> ht=new HashTable<Integer,String>();  


[1=Deo, 2=zen, 3=porter ,4=piter]

Prev Tutorial Next Tutorial


Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements

Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs