1, through the key set access, to key interest, you can access the value corresponding to the key;
For (String K:maps.keyset ()) {
System.out.println (k +: +maps.get);
}
2, through the value set access, only the value of interest, can not access the key value;
For (String value:maps.values ()) {
System.out.println (value);
}
3, through entry collection access, interested in entry, you can access the value corresponding to the key
For (Entry Entry:maps.entrySet ()) {
System.out.println (Entry.getkey () + ":" +entry.getvalue ());
}
4, through the iteration key set to access the Map collection, Maps.keyset () returns a Set<string> collection, the set directly inherits collection, so you can iterate over it.
Iterator<string> iterator = Maps.keyset (). iterator ();
while (Iterator.hasnext ()) {
String key = Iterator.next ();
System.out.println (key+ ":" +maps.get (key));
}
5. Access to the map collection through the iteration values collection, Maps.values () returns the Collection<string>, so you can iterate over it.
Iterator<string> iter= maps.values (). iterator ();
while (Iter.hasnext ()) {
System.out.println (Iter.next ());
}
6, through the iterative Entry collection to access the Map collection, Maps.entryset () returns a set<entry<string, String>>,set directly inherit collection, so you can iterate over it.
Iterator<entry<string, string>> it = Maps.entryset (). iterator ();
while (It.hasnext ()) {
entry<string, string> Entry = It.next ();
System.out.println (Entry.getkey () + ":" +entry.getvalue ());
}