|
The Map interface defines methods that map keys to values. A
Map cannot
contain duplicate keys.
Note that Map is at the root of a distinct interface
hierarchy, and so it is
not strictly speaking a true collection.
Collection
List
Set
SortedSet
Comparable (in java.lang package)
Comparator
Enumeration
Iterator
ListIterator
Map
SortedMap
A Map
is not really a
collection of elements, but a mapping of keys to values.
Map defines the following methods:
package java.util;
public interface Map
{
// Query Operations
int size();
boolean isEmpty();
boolean containsKey(Object key);
boolean containsValue(Object value);
Object get(Object key);
// Modification Operations
Object put(Object key, Object value);
Object remove(Object key);
// Bulk Operations
void putAll(Map t);
void clear();
// Views
/**
* Returns a set view of the keys contained in this map.
*/
public Set keySet();
/**
* Returns a collection view of the values contained in this map.
*/
public Collection values();
/**
* Returns a set view of the mappings contained in this map.
*/
public Set entrySet();
/**
* A map entry (key-value pair).
*/
public interface Entry
{
Object getKey();
Object getValue();
Object setValue(Object value);
boolean equals(Object o);
int hashCode();
}
// Comparison and hashing
/**
* Compares the specified object with this map for equality.
*/
boolean equals(Object o);
/**
* Returns the hash code value for this map.
*/
int hashCode();
}
|
|