Java HashTable Tutorial with Example program



Class Hashtable
:

Type Parameters:
K - the type of keys maintained by this map
V - the type of mapped values


All Implemented Interfaces:
    Serializable, Cloneable, Map
   
Direct Known Subclasses:
    Properties, UIDefaults

public class Hashtable
extends Dictionary
implements Map, Cloneable, Serializable
{
   //

}

Since:
    JDK1.0
   
See Also:
    Object.equals(java.lang.Object), Object.hashCode(), rehash(), Collection, Map, HashMap, TreeMap, Serialized Form

Constructor summary
Hashtable()
    Constructs a new, empty hashtable with a default initial capacity (11) and load factor (0.75).

Hashtable(int initialCapacity)
    Constructs a new, empty hashtable with the specified initial capacity and default load factor (0.75).

Hashtable(int initialCapacity, float loadFactor)
    Constructs a new, empty hashtable with the specified initial capacity and the specified load factor.
   
Hashtable(Map t)
    Constructs a new hashtable with the same mappings as the given Map.

Methods summary

void clear()
    Clears this hashtable so that it contains no keys.
   
Object clone()
    Creates a shallow copy of this hashtable.
   
boolean contains(Object value)
    Tests if some key maps into the specified value in this hashtable.
   
boolean containsKey(Object key)
    Tests if the specified object is a key in this hashtable.
   
boolean containsValue(Object value)
    Returns true if this hashtable maps one or more keys to this value.
   

Enumeration elements()
    Returns an enumeration of the values in this hashtable.
   
Set entrySet()
    Returns a Set view of the mappings contained in this map.
   
boolean equals(Object o)
    Compares the specified Object with this Map for equality, as per the definition in the Map interface.
   
V get(Object key)
    Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
   
int hashCode()
    Returns the hash code value for this Map as per the definition in the Map interface.
   
boolean isEmpty()
    Tests if this hashtable maps no keys to values.
   
Enumeration keys()
    Returns an enumeration of the keys in this hashtable.
   
Set keySet()
    Returns a Set view of the keys contained in this map.
   
V put(K key, V value)
    Maps the specified key to the specified value in this hashtable.
   
void putAll(Map t)
    Copies all of the mappings from the specified map to this hashtable.
   
protected void    rehash()
    Increases the capacity of and internally reorganizes this hashtable, in order to accommodate and access its entries more efficiently.
   
V remove(Object key)
    Removes the key (and its corresponding value) from this hashtable.
   
int size()
    Returns the number of keys in this hashtable.
   
String toString()
    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).
   
Collection values()
    Returns a Collection view of the values contained in this map.
   
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait



Related Post

Comments


©candidjava.com