Hashtable class

Hashtable class:

HashTable is used to store key-value pair in the form of objects.

The datastructure of HashTable class is HashTable.

HashTable allows Heterogeneous objects.

HashTable doenot allow null values for both key and value.if we try to insert null value we will get nullpointer exception.

In HashTable Insertion order is not preserved.insertion is based on the Hashcode of the keys.

In Hashtable keys must implement the hashCode method and the equals method.

HashTable will not allow duplicate Keys.But It can allow duplicate values.

All methods present in HashTable are synchronized.At any point of time only one thread is allowed to operate on HashTable Object.so HashTable Object is Threadsafe.

Hashtable implements serializable and cloneable interfaces.


HashTable h = new HashTable();

This constructor creates an empty Hashtable object with default initial capacity of "11" .

HashTable h = new HashTable(int initial capacity);

HashTable h = new HashTable(int initial capacity,float fillratio);

HashMap h = new hashTable(map m);

No comments:

Post a Comment