Map of the Java Collection framework.
The main implementation classes of map are Hashmap,linkedhashmap,treemap, and so on. Refer to the API documentation for details.
Where HashMap is unordered ordering.
Linkedhashmap is a natural sort, first-time mapping.
The TREEMAP key cannot be null, but the value can be null,treemap the same as the data type of the key.
Hashtable keys and values are not nullable.
Here's a bit of code to feel.
Map map = Newhashmap (); Map.put (1, "a"); Map.put (2, "B"); Map.put (3, "C"); Map.put (nullnull); Map.put (null, "D"); // hashmap keys and values can be null // to make a collection of key values
In map, find a Get method, inside is the key value of the object collection, the Map.keyset () method will return the collection of key values.
Set set = Map.keyset (); // Set the key value as a collection = Set.iterator (); // constructs an iterator while (It.hasnext ()) {// to determine if there are elements, returned as Boolean System.out.println (Map.get (It.next ())); // if the key is the same, the value is overwritten }
The output is: D
A
B
C
When the key is converted to the set set, NULL is the same, so within set, the first null object is overwritten by the second null object and HashMap is unordered.
Hashmap,linkedhashmap,treemap and so on. Map implementations are similar.
Map of the Java Collection framework