Map interface in Collection

The Map interface is not an extension of Collection interface. Instead the interface starts of it’s own interface hierarchy, for maintaining key-value associations. The interface describes a mapping from keys to values, without duplicate keys, by definition.

The Map interface provides three collection views, which allow a map’s contents to be viewed as a set of keys, collection of values, or set of key-value mappings. The order of a map is defined as the order in which the iterators on the map’s collection views return their elements. Some map implementations, like the TreeMap class, make specific guarantees as to their order; others, like the HashMap class, do not. 

Removes all mappings from this map (optional operation).
containsKey(Object key)
Returns true if this map contains a mapping for the specified key.
containsValue(Object value)
Returns true if this map maps one or more keys to the specified value.
Returns a set view of the mappings contained in this map.
equals(Object o)
Compares the specified object with this map for equality.
get(Object key)
Returns the value to which this map maps the specified key.
Returns the hash code value for this map.
Returns true if this map contains no key-value mappings.
Returns a set view of the keys contained in this map.
put(Object key, Object value)
Associates the specified value with the specified key in this map (optional operation).
putAll(Map t)
Copies all of the mappings from the specified map to this map (optional operation).
remove(Object key)
Removes the mapping for this key from this map if it is present (optional operation).
Returns the number of key-value mappings in this map.
Returns a collection view of the values contained in this map.

The interface methods can be broken down into three sets of operations: altering, querying and providing alternative views

Map interface in Collection

The alteration operation allows you to add and remove key-value pairs from the map. Both the key and value can be null. However you should not add a Map to itself as a key or value.
Object put(Object key, Object value)
Object remove(Object key)
void putAll(Map t)
void clear()

The query operations allow you to check on the contents of the map
Object get(Object key)
boolean containsKey(Object key)
boolean containsValue(Object value)
int size()
boolean isEmpty()

The set methods allow you to work with the group ofkeys or values as a collection
Set keySet()
Collection values()
Set entrySet()

<<Previous <<   || Index ||   >>Next >>