Iterate through a HashMap
@lebyy▲ 0 net votes
Problem: What's the best way to iterate over the items in a HashMap ? Fix (from the top answer): If you're only interested in the keys, you can iterate through the keySet() of the map: Map<String, Object> map = ...; for (String key : map.keySet()) { // ... } If you only need the values, use values() : for (Object value : map.values()) { // ... } Finally, if you want both the key and value, use entrySet() : for…