Known Direct Subclasses
| Properties |
Properties is a Hashtable where the keys and values must be Strings. |
|
Known Indirect Subclasses
|
Class Overview
Hashtable associates keys with values. Keys and values cannot be null. The
size of the Hashtable is the number of key/value pairs it contains. The
capacity is the number of key/value pairs the Hashtable can hold. The load
factor is a float value which determines how full the Hashtable gets before
expanding the capacity. If the load factor of the Hashtable is exceeded, the
capacity is doubled.
Summary
| Public Constructors |
|
|
Hashtable()
Constructs a new Hashtable using the default capacity and load factor.
|
|
|
Hashtable(int capacity)
Constructs a new Hashtable using the specified capacity and the default
load factor.
|
|
|
Hashtable(int capacity, float loadFactor)
Constructs a new Hashtable using the specified capacity and load factor.
|
|
|
Hashtable(Map<? extends K, ? extends V> map)
Constructs a new instance of Hashtable containing the mappings from the
specified Map.
|
| Public Methods |
|
synchronized
void
|
clear()
Removes all key/value pairs from this Hashtable, leaving the size zero
and the capacity unchanged.
|
|
synchronized
Object
|
clone()
Returns a new Hashtable with the same key/value pairs, capacity and load
factor.
|
|
synchronized
boolean
|
contains(Object value)
Returns if this Hashtable contains the specified object as the value of
at least one of the key/value pairs.
|
|
synchronized
boolean
|
containsKey(Object key)
Returns if this Hashtable contains the specified object as a key of one
of the key/value pairs.
|
|
boolean
|
containsValue(Object value)
Searches this Hashtable for the specified value.
|
|
synchronized
Enumeration<V>
|
elements()
Returns an Enumeration on the values of this Hashtable.
|
|
Set<Entry<K, V>>
|
entrySet()
Returns a Set of the mappings contained in this Hashtable.
|
|
synchronized
boolean
|
equals(Object object)
Compares the specified object to this Hashtable and answer if they are
equal.
|
|
synchronized
V
|
get(Object key)
Returns the value associated with the specified key in this Hashtable.
|
|
synchronized
int
|
hashCode()
Returns an integer hash code for the receiver.
|
|
synchronized
boolean
|
isEmpty()
Returns if this Hashtable has no key/value pairs, a size of zero.
|
|
Set<K>
|
keySet()
Returns a Set of the keys contained in this Hashtable.
|
|
synchronized
Enumeration<K>
|
keys()
Returns an Enumeration on the keys of this Hashtable.
|
|
synchronized
V
|
put(K key, V value)
Associate the specified value with the specified key in this Hashtable.
|
|
synchronized
void
|
putAll(Map<? extends K, ? extends V> map)
Copies every mapping in the specified Map to this Hashtable.
|
|
synchronized
V
|
remove(Object key)
Remove the key/value pair with the specified key from this Hashtable.
|
|
synchronized
int
|
size()
Returns the number of key/value pairs in this Hashtable.
|
|
synchronized
String
|
toString()
Returns the string representation of this Hashtable.
|
|
Collection<V>
|
values()
Returns a Collection of the values contained in this Hashtable.
|
| Protected Methods |
|
void
|
rehash()
Increases the capacity of this Hashtable.
|
|
[Expand]
Inherited Methods |
From class java.util.Dictionary
|
abstract
Enumeration<V>
|
elements()
Returns an Enumeration on the elements of this Dictionary.
|
|
abstract
V
|
get(Object key)
Returns the value associated with key.
|
|
abstract
boolean
|
isEmpty()
Returns if this Dictionary has no key/value pairs, a size of zero.
|
|
abstract
Enumeration<K>
|
keys()
Returns an Enumeration on the keys of this Dictionary.
|
|
abstract
V
|
put(K key, V value)
Associate key with value in this
Dictionary.
|
|
abstract
V
|
remove(Object key)
Remove the key/value pair with the specified key from this
Dictionary.
|
|
abstract
int
|
size()
Returns the number of key/value pairs in this Dictionary.
|
|
From class java.lang.Object
|
Object
|
clone()
Returns a new instance of the same class as the receiver, whose slots
have been filled in with the values in the slots of the receiver.
|
|
boolean
|
equals(Object o)
Compares the argument to the receiver, and returns true if they represent
the same object using a class specific comparison.
|
|
void
|
finalize()
Called by the virtual machine when there are no longer any (non-weak)
references to the receiver.
|
|
final
Class<? extends Object>
|
getClass()
Returns the unique instance of java.lang.Class which represents the class
of the receiver.
|
|
int
|
hashCode()
Returns an integer hash code for the receiver.
|
|
final
void
|
notify()
Causes one thread which is wait ing on the receiver to be
made ready to run.
|
|
final
void
|
notifyAll()
Causes all threads which are wait ing on the receiver to
be made ready to run.
|
|
String
|
toString()
Returns a string containing a concise, human-readable description of the
receiver.
|
|
final
void
|
wait(long time, int frac)
Causes the thread which sent this message to be made not ready to run
either pending some change in the receiver (as indicated by
notify or notifyAll) or the expiration of
the timeout.
|
|
final
void
|
wait(long time)
Causes the thread which sent this message to be made not ready to run
either pending some change in the receiver (as indicated by
notify or notifyAll) or the expiration of
the timeout.
|
|
final
void
|
wait()
Causes the thread which sent this message to be made not ready to run
pending some change in the receiver (as indicated by notify
or notifyAll).
|
|
From interface java.util.Map
|
abstract
void
|
clear()
Removes all elements from this Map, leaving it empty.
|
|
abstract
boolean
|
containsKey(Object key)
Searches this Map for the specified key.
|
|
abstract
boolean
|
containsValue(Object value)
Searches this Map for the specified value.
|
|
abstract
Set<Entry<K, V>>
|
entrySet()
Returns a Set whose elements comprise all of the mappings
that are to be found in this Map.
|
|
abstract
boolean
|
equals(Object object)
Compares the argument to the receiver, and returns true if they represent
the same object using a class specific comparison.
|
|
abstract
V
|
get(Object key)
Returns the value of the mapping with the specified key.
|
|
abstract
int
|
hashCode()
Returns an integer hash code for the receiver.
|
|
abstract
boolean
|
isEmpty()
Returns if this Map has no elements, a size of zero.
|
|
abstract
Set<K>
|
keySet()
Returns a Set of the keys contained in this Map.
|
|
abstract
V
|
put(K key, V value)
Maps the specified key to the specified value.
|
|
abstract
void
|
putAll(Map<? extends K, ? extends V> map)
Copies every mapping in the specified Map to this Map.
|
|
abstract
V
|
remove(Object key)
Removes a mapping with the specified key from this Map.
|
|
abstract
int
|
size()
Returns the number of elements in this Map.
|
|
abstract
Collection<V>
|
values()
Returns all of the current Map values in a
Collection.
|
|
Public Constructors
public
Hashtable
()
Constructs a new Hashtable using the default capacity and load factor.
public
Hashtable
(int capacity)
Constructs a new Hashtable using the specified capacity and the default
load factor.
Parameters
| capacity
| the initial capacity
|
public
Hashtable
(int capacity, float loadFactor)
Constructs a new Hashtable using the specified capacity and load factor.
Parameters
| capacity
| the initial capacity |
| loadFactor
| the initial load factor
|
public
Hashtable
(Map<? extends K, ? extends V> map)
Constructs a new instance of Hashtable containing the mappings from the
specified Map.
Public Methods
public
synchronized
void
clear
()
Removes all key/value pairs from this Hashtable, leaving the size zero
and the capacity unchanged.
public
synchronized
Object
clone
()
Returns a new Hashtable with the same key/value pairs, capacity and load
factor.
Returns
- a shallow copy of this Hashtable
public
synchronized
boolean
contains
(Object value)
Returns if this Hashtable contains the specified object as the value of
at least one of the key/value pairs.
Parameters
| value
| the object to look for as a value in this Hashtable |
Returns
- true if object is a value in this Hashtable, false otherwise
public
synchronized
boolean
containsKey
(Object key)
Returns if this Hashtable contains the specified object as a key of one
of the key/value pairs.
Parameters
| key
| the object to look for as a key in this Hashtable |
Returns
- true if object is a key in this Hashtable, false otherwise
public
boolean
containsValue
(Object value)
Searches this Hashtable for the specified value.
Parameters
| value
| the object to search for |
Returns
- true if
value is a value of this Hashtable, false
otherwise
public
synchronized
Enumeration<V>
elements
()
Returns an Enumeration on the values of this Hashtable. The results of
the Enumeration may be affected if the contents of this Hashtable are
modified.
Returns
- an Enumeration of the values of this Hashtable
public
Set<Entry<K, V>>
entrySet
()
Returns a Set of the mappings contained in this Hashtable. Each element
in the set is a Map.Entry. The set is backed by this Hashtable so changes
to one are reflected by the other. The set does not support adding.
public
synchronized
boolean
equals
(Object object)
Compares the specified object to this Hashtable and answer if they are
equal. The object must be an instance of Map and contain the same
key/value pairs.
Parameters
| object
| the object to compare with this object |
Returns
- true if the specified object is equal to this Map, false
otherwise
public
synchronized
V
get
(Object key)
Returns the value associated with the specified key in this Hashtable.
Parameters
| key
| the key of the value returned |
Returns
- the value associated with the specified key, null if the
specified key does not exist
public
synchronized
int
hashCode
()
Returns an integer hash code for the receiver. Objects which are equal
answer the same value for this method.
public
synchronized
boolean
isEmpty
()
Returns if this Hashtable has no key/value pairs, a size of zero.
Returns
- true if this Hashtable has no key/value pairs, false otherwise
public
Set<K>
keySet
()
Returns a Set of the keys contained in this Hashtable. The set is backed
by this Hashtable so changes to one are reflected by the other. The set
does not support adding.
public
synchronized
Enumeration<K>
keys
()
Returns an Enumeration on the keys of this Hashtable. The results of the
Enumeration may be affected if the contents of this Hashtable are
modified.
Returns
- an Enumeration of the keys of this Hashtable
public
synchronized
V
put
(K key, V value)
Associate the specified value with the specified key in this Hashtable.
If the key already exists, the old value is replaced. The key and value
cannot be null.
Parameters
| key
| the key to add |
| value
| the value to add |
Returns
- the old value associated with the specified key, null if the key
did not exist
public
synchronized
void
putAll
(Map<? extends K, ? extends V> map)
Copies every mapping in the specified Map to this Hashtable.
Parameters
| map
| the Map to copy mappings from
|
public
synchronized
V
remove
(Object key)
Remove the key/value pair with the specified key from this Hashtable.
Returns
- the value associated with the specified key, null if the
specified key did not exist
public
synchronized
int
size
()
Returns the number of key/value pairs in this Hashtable.
Returns
- the number of key/value pairs in this Hashtable
public
synchronized
String
toString
()
Returns the string representation of this Hashtable.
Returns
- the string representation of this Hashtable
Returns a Collection of the values contained in this Hashtable. The
collection is backed by this Hashtable so changes to one are reflected by
the other. The collection does not support adding.
Returns
- a Collection of the values
Protected Methods
protected
void
rehash
()
Increases the capacity of this Hashtable. This method is sent when the
size of this Hashtable exceeds the load factor.