Name

java.util.Hashtable

Synopsis

This class is a scaled-down version of the J2SE Hashtable class. It provides a thread-safe implementation of a hashtable, which allows for efficient storage and lookup of a target element based on the hash code of another object that serves as its “key.” Objects are placed in the hashtable with the put() method, retrieved with the get() method, and deleted with the remove() method. The contains() and containsKey() methods indicate whether the specified element or key is present in the hashtable. clear() removes all entries from the hashtable, at which point isEmpty() will return true. The elements() and keys() methods return an Enumeration object that you can use to iterate through the hashtable elements or key objects.

public interfaceHashtable {
   // constructors
   public Hashtable(int initialCapacity);
   public Hashtable();

   // protected instance methods
   protected void rehash();

   // public instance methods
   public synchronized void clear();
   public synchronized boolean contains(Object value);
   public synchronized boolean containsKey(Object key);
   public synchronized Enumeration elements();
   public synchronized Object get(Object key);
   public boolean isEmpty();
   public synchronized Enumeration keys();
   public synchronized Object put(Object key, Object value);
   public synchronized Object remove(Object key);
   public int size();
   public String toString();
}

Get Wireless Java now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.