Java Reference
In-Depth Information
public V get(Object key)
Returns the object to which key is mapped, or null if it is not
mapped. Also returns null if key has been mapped to null in
a map that allows null values. You can use containsKey to dis-
tinguish between the cases, although this adds overhead. It
can be more efficient to put marker objects instead of null in-
to the map to avoid the need for the second test.
public V put(K key, V value)
Associates key with the given value in the map. If a map
already exists for key , its value is changed and the original
value is returned. If no mapping exists, put returns null ,
which may also mean that key was originally mapped to null .
(Optional)
public V remove(Object key)
Removes any mapping for the key . The return value has the
same semantics as that of put . (Optional)
public void putAll(Map< ? extends K, ? extends V> otherMap)
Puts all the mappings in otherMap into this map. (Optional)
public void clear()
Removes all mappings. (Optional)
Methods that take keys as parameters may throw ClassCastException if
the key is not of the appropriate type for this map, or NullPointerExcep-
tion if the key is null and this map does not accept null keys.
You can see that, though Map does not extend Collection , methods with
the same meaning have the same names, and analogous methods have
 
Search WWH ::




Custom Search