Summay: The Map Interface, Collection implementations
-Maps store and retrieve elements with key values
e.g:
dateMap.put( "today", new Date() );
Date today = dateMap.get( "today" );
-Functions:
public V get( K key )//This method retrieves the value corresponding to key from the map.
public V remove( K key )//This method removes the value corresponding to key from the map
public int size()//Use this method to find the number of key/value pairs in this map
public Set keySet()//This method returns a Set that contains all the keys in this map.
public Collection values()//Use this method to retrieve all the values in this map
-Map has one child interface, SortedMap . A SortedMap maintains its key/value pairs sorted
in a particular order according to the key values.
-All of the methods of the Collection interface would appear to make sense for Map ,
except for iterator() . A Map , again, has two sets of objects: keys and values, and separate
iterators for each. This is why a Map does not implement Collection
-ConcurrentMap, It extends the base Map interface and adds atomic put, remove, and replace functionality that is
useful for concurrent programming
public boolean remove( Object key, Object value )//This method removes the mapping (key and value) only if the current value asso
波比源码 » Java Notes-10