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 publicHashtable
(int initialCapacity); publicHashtable
(); // protected instance methods protected voidrehash
(); // public instance methods public synchronized voidclear
(); public synchronized booleancontains
(Object value); public synchronized booleancontainsKey
(Object key); public synchronized Enumerationelements
(); public synchronized Objectget
(Object key); public booleanisEmpty
(); public synchronized Enumerationkeys
(); public synchronized Objectput
(Object key, Object value); public synchronized Objectremove
(Object key); public intsize
(); public StringtoString
(); }
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.