Gets the value of the Map

Map values ​​are as follows

Map<String,Object> map = new HashMap<>();
map.put("key1","value1");
map.put("key2","value2");
map.put("key3","value3");

1, in the case of a known key deserve to get the value in the Map

Object value1 = map.get("key1");
Object value2 = map.get("key2");
Object value3 = map.get("key3");

2, Map obtain the value of the key in the case of unknown

map.entrySet()
Set<Entry<String,Object>> entry = map.entrySet();
for(Entry<String,Object> value:entry){
	value.getValue();
}
map.keySet()
for(String key:map.keySet()){
	map.get(key);
}
Published 24 original articles · won praise 1 · views 2431

Guess you like

Origin blog.csdn.net/qq_35018214/article/details/103577325