This class implements
Map using an internal hashtable. It is similar in
features and performance to HashMap, except that
it uses the capabilities of the java.lang.ref
package, so that the key-to-value mappings it maintains do not
prevent the key objects from being reclaimed by the garbage
collector. When there are no more references to a key object except
for the weak reference maintained by the
WeakHashMap, the garbage collector reclaims the
object, and the WeakHashMap deletes the mapping
between the reclaimed key and its associated value. If there are no
references to the value object except for the one maintained by the
WeakHashMap, the value object also becomes
available for garbage collection. Thus, you can use a
WeakHashMap to associate an auxiliary value with
an object without preventing either the object (the key) or the
auxiliary value from being reclaimed. See HashMap
for a discussion of the implementation features of this class. See
Map for a description of the methods it defines.
WeakHashMap is
primarily useful with objects whose equals( )
methods use the == operator for comparison. It is
less useful with key objects of type String, for
example, because there can be multiple String
objects that are equal to one another and, even if the original key
value has been reclaimed by the garbage collector, it is always
possible to pass a String with the same value to
the get( ) method.

public class WeakHashMap<K,V> extends AbstractMap<K,V> implements Map<K,V> {
// Public Constructors
public WeakHashMap( );
public WeakHashMap(int initialCapacity);
1.3 public WeakHashMap(Map<? extends K,? extends V> t);
public WeakHashMap(int initialCapacity, float loadFactor);
// Methods Implementing Map
public void clear( );
public boolean containsKey(Object key);
1.4 public boolean containsValue(Object value);
public Set<Map.Entry<K,V>> entrySet( );
public V get(Object key);
public boolean isEmpty( ); default:true
1.4 public Set<K> keySet( );
public V put(K key, V value);
1.4 public void putAll(Map<? extends K,? extends V> m);
public V remove(Object key);
public int size( );
1.4 public Collection<V> values( );
}