Hashtable
A Hashtable was category of the real java.util and is a concrete implementation of a dictionary. Moreover, Java2 reengineered Hashtable so which it also implements the map interface. Therefore, Hashtable is now integrated into the collections framework. It is same to HashMap, but is synchronized.
Such as HashMap, Hashtable stores key and value pairs in a hash table. Whenever using a Hashtable, you specify an object which is used as a key, and the value which you need linked to that key. That key is then hashed, and the concluded hash code is used as the index at that the value is stored inside the table.
A hash table can just store objects which override the hashCode() and equals() methods which are defined through object. A hashCode() method have to compute and return the hash code for the object. Actually, equals () compares two objects. Fortunately, several of Java's built-in classes already implement the hashCode() method. For instance, the most general type of Hashtable uses a String object as the key. A String implements hashCode() and equals()both.
The Hashtable constructors are displays here:
Hashtable()
Hashtable(int size)
Hashtable(int size, float fillratio)
Hashtable(Map m)
The 1st version of Hash table is the default constructor. The 2nd version creates a hash table which has an initial size specified through size. The 3rd version creates a hash table which has an initial size specified through size and a fill ratio specified through fillratio. This ratio must be among 0.0 and 1.0. And it determines how full the hash table is expected. 0.75 is used if you do not specify a fill ratio. At last, the 4th version creates a hash table which is initialized along with the elements in m. A capacity of the hash table is set to double the number of elements in m. The default load factor of 0.75 is used. The 4th constructor was added through Java 2.
Further to the methods declared through the Map interface, that Hashtable now implements, Hashtable declared the legacy methods