Common Operating Instructions
void Clear ()
Removes all mapping relationships from this mapping (optional).
Boolean ContainsKey (Object key)
Returns TRUE if this map contains a mapping relationship for the specified key.
Boolean Containsvalue (Object value)
Returns true if the map maps one or more keys to the specified value.
Set<map.entry<k,v>> EntrySet ()
Returns a Set view of the mapping relationships contained in this map.
Boolean equals (Object O)
Compares whether the specified object is equal to this mapping.
V get (Object key)
Returns the value mapped by the specified key, or null if the mapping does not contain a mapping relationship for the key.
int Hashcode ()
Returns the hash code value for this mapping.
Boolean IsEmpty ()
Returns true if the mapping does not contain a key-value mapping relationship.
Set<k> KeySet ()
Returns a Set view of the keys contained in this map.
V Put (K key, V value)
Associates the specified value with the specified key in this map (optional operation).
void Putall (map<? extends K,? extends v> m)
Copies all mappings from the specified map to this map (optional operation).
V Remove (Object key)
If there is a mapping of a key, it is removed from this mapping (optional operation).
int size ()
Returns the number of key-value mapping relationships in this map.
Collection<v> VALUES ()
Returns a Collection view of the values contained in this map.
General usage of Map
1. Declare a map :
Map map = new HashMap ();
2 . Place values in map , Note: Map is stored in key-value form, such as:
Map.put ("sa", "DD");
3 . To take a value from the map :
String str = map.get ("sa"). ToString,
The result is: str = "DD"
4 . traverse a map to get the key and value from :
Map m= new HashMap ();
For (Object Obj:map.keySet ()) {
Object value = map.get (obj);
}
5 traverse the keyset in a map:
Map map = new HashMap ();
Map.put ("Key", "value");
Set set = Map.keyset ();
Iterator it = Set.iterator ();
Object object = It.next ();
Key
Object.ToString (); Value
Map.get (object);
Map interface Methods for Java