遍历Map的优化

我原来遍历Map是这样遍历的:
Map<String,Object> map = new HashMap<String,Object>();
Set<String> keySet = map.keySet();
for (String key : keySet) {
Object o = map.get(key);
}
被findBug找到后,优化为:
Set<Entry<String,Object>> entrySet = map.entrySet();
for (Entry<String, Object> entry : entrySet) {
Object o = entry.getValue();
}

你可能感兴趣的:(map)