Map<String, String> map = new HashMap<String, String>();
map.put("firstname", "Zhou");
map.put("lastname", "Shuai");
-----------------------------------------------------
Iterate 1:
Set<K>
keySet()
Returns a Set view of the keys contained in this map.
Set<String> set = map.keySet();
for (String str: set) {
System.out.println(str + ": " + map.get(str));
}
Iterate 2:
Set<Map.Entry<K,V>>
entrySet()
Returns a Set view of the mappings contained in this map.
Set<Map.Entry<String, String>> set = map.entrySet();
for (Map.Entry<String, String> entry: set) {
System.out.println(entry.getKey() + ": " + entry.getValue);
}