Java.util.Hashtable Class

The java.util.Hashtable class implements a hashtable, which maps keys to values.Following are the important points about Hashtable −
In this any non-null object can be used as a key or as a value.
In this any non-null object can be used as a key or as a value.
If many entries are to be made into a Hashtable, creating it with a sufficiently large capacity may allow the entries to be inserted more efficiently than letting it perform automatic rehashing as needed to grow the table.
If many entries are to be made into a Hashtable, creating it with a sufficiently large capacity may allow the entries to be inserted more efficiently than letting it perform automatic rehashing as needed to grow the table.
Following is the declaration for java.util.Hashtable class −
public class Hashtable<K,V>
   extends Dictionary<K,V>
   implements Map<K,V>, Cloneable, Serializable

Hashtable()
This constructs a new, empty hashtable with a default initial capacity (11) and load factor (0.75).
Hashtable(int initialCapacity)
This constructs a new, empty hashtable with the specified initial capacity and default load factor (0.75).
Hashtable(int initialCapacity, float loadFactor)
This constructs a new, empty hashtable with the specified initial capacity and the specified load factor.
Hashtable(Map<? extends K,? extends V> t)
This constructs a new hashtable with the same mappings as the given Map.
This method clears this hashtable so that it contains no keys.
This method creates a shallow copy of this hashtable.
This method tests if some key maps into the specified value in this hashtable.
This method tests if the specified object is a key in this hashtable.
This method returns true if this hashtable maps one or more keys to this value.
This method returns an enumeration of the values in this hashtable.
This method returns a Set view of the mappings contained in this map.
This method compares the specified Object with this Map for equality, as per the definition in the Map interface.
This method returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
This method returns the hash code value for this Map as per the definition in the Map interface.
This method tests if this hashtable maps no keys to values.
This method returns an enumeration of the keys in this hashtable.
This method returns a Set view of the keys contained in this map.
This method maps the specified key to the specified value in this hashtable.
This method copies all of the mappings from the specified map to this hashtable.
This method increases the capacity of and internally reorganizes this hashtable, in order to accommodate and access its entries more efficiently.
This method removes the key (and its corresponding value) from this hashtable.
This method returns the number of keys in this hashtable.
This method returns a string representation of this Hashtable object in the form of a set of entries, enclosed in braces and separated by the ASCII characters ", " (comma and space).
This method returns a Collection view of the values contained in this map.
This class inherits methods from the following classes −
java.util.Object
 Print
 Add Notes
 Bookmark this page