Map Collection set not inherited interfaces, provided that the value of the key to the map is stored in the key - value pairs - a set of (key value) of;
To identify the position of the object stored in the map by the key, the key can not be repeated, the key itself can not decide to store position, but by a hashing technique process produces an integral value of a hash code;
Hash code used for the offset, the offset corresponding to the memory area assigned to the start position of mapping, to determine the position of the object is stored in the memory map;
When a call is not mapped elements are present, NoSuchElementException throws an exception, when the object is not compatible with the map elements, will lead ClassCastException exception if the map does not permit the use of null object will cause a NullPointerException when trying to change a is not allowed to modify the map, it will lead to an UnsupportedOperationException;
1. Conversion to set (Set, Collection)
Mapping is not cluster, but the view can be obtained cluster can be used the entrySet () method which returns a collection mapping elements (the Set), can be obtained clusters view of the keys with keySet (), with the values () clusters can be worth view;
Types of
method
Explanation
Set
entrySet()
Returns a collection of all the keys Map - Set the value of the set of data elements in a set type Set is Map.Entry
Set
keySet()
Set to return a collection of all the keys in the corresponding Map
Collection
values()
Returns a set of classes worth maps contain mapping recycling get () and put (), put () specifies a value of the key will be added to the map, the key may be used as a parameter to call get () method returns the value
2. The method provided
Types of
method
Explanation
Object
put(Object key, Object value)
Map set to add key - value pair, the key returns the corresponding value before the null if none
void
putAll (Map m)
All incoming calls from the map is added m
Object
get(Object key)
Returns the value of the key mapping, if this map contains no mapping for the key return null, Object value data type