A map M: D &rarr R associates an element of its domain with an element of its range.
We can think of a map as a lookup table that allows us to look up information given a key value; for example, a telephone directory lets us look up a name to find a phone number: Directory: Name &rarr Number.
A Map is an interface to a Collection that associates keys with values. A key is unique, but different keys can map to the same value. A TreeMap maintains a map in sorted order; operations are O(log(n)). There is also a HashMap, O(1).
boolean containsKey( KeyType key ) ValueType get ( KeyType key ) ValueType put ( KeyType key, ValueType value ) ValueType remove ( KeyType key )
put returns the old value associated with key, or null if there was no old value.
Contents    Page-10    Prev    Next    Page+10    Index