Map of Java collection framework
Map:
Add a pair of elements at a time (key - > value)
Two column set, key value pair
Common methods:
1. Add
V put (k key, V value) will update the value corresponding to the key and return the replaced value
2. Delete
Clear (): clear the collection
V remove (k key): deletes the key value pair according to the specified key
3. Judgment:
Boolean containsKey(key)
Boolean containsValue(value);
Boolean isEmpty();
4. Get
Value get (key): get the value through the key. If there is no key, null will be returned.
Int size(): get the number of key value pairs
Common subclasses of map:
Hashtable (available in 1.0): the internal structure is a hash table, which is synchronous. Null is not allowed as a key or value
Hashtable subclass: properties is used to store the configuration information of key value pair type and cooperate with io
HashMap: the internal hash table is out of sync. Null is allowed as key or value
Treemap: it is a binary tree inside. It is out of sync and can sort the keys in the collection
demo: