[Java learning notes] Map, learning notes map
Map:
Add one element at a time, also known as a double row set.
WhileCollectionAdd an element at a time, called a single column set.
Common Methods: 1. Add
Value put (key, value); returns the value associated with the key. If not, null is returned.
2. Delete
Void clear (); clears the map set.
Value remove (key); returns the value associated with the specified key and deletes the key-value pair. If no key is specified, null is returned.
3. Judgment
Boolean containsKey (key );
Boolean containsValue (value );
Boolean isEmpty ();
4. Get
Value get (key): get the value through the key. If the key is not found, null is returned. Of course, null can be returned to determine whether the specified key is included.
Int size (); gets the number of key-value pairs.
Common subclass of Map: | -- HashTable:
The internal structure is a hash table, which is synchronous and does not allow null as the key or null as the value.
| -- Properties: stores information about key-Value Pair configuration files, which can be combined with IO technology.
| -- HashMap:
The internal structure is a hash table, not synchronous. Allow null as the key and null as the value.
| -- TreeMap:
The internal structure is a binary tree, not synchronous. You can sort keys in the Map set.