Map collection type resolution

Use Map set, map key set is provided to the mapping value. map can have the same key, and each key can map a value.

And map-related common methods include:
PUT (Key K, V value)
GET (Object Key)
keySet ()
values ()
, such as:
the Map <String, String> = new new map the HashMap <> ();
map.put ( "01 "" Lee students ");
map.put (" 02 "," King of the students ");
the set set = map.keySet (); // return all objects form a set of key collection
Iterator it = set.iterator ();
System.out.println ( "key collection element");
the while (it.hasNext) {
System.out.println (it.next ());
}

Map type implementation class has HashMap and TreeMap, HashMap recommended map to achieve the set, because it higher to add and remove mapping between efficiency. TreeMap mapping is set according to a sequence and find inefficient,

Published 13 original articles · won praise 4 · Views 3124

Guess you like

Origin blog.csdn.net/leadder/article/details/104034270