[Java] Map 순회 방법
·
Java
자바 컬렉션 중 하나인 Map을 순회하는 방법 3가지를 간단히 알아보겠습니다. 1. Iterator Map map = new HashMap(); Iterator it = map.keySet().iterator(); whlie(it.hasNest()) { String key = it.next(); int value = map.get(key); } 2. Entry Map map = new HashMap(); for(Map.Entry entry : map.entrySet()) { String key = entry.getKey(); int value = entry.getValue(); } 3. keySet() Map map = new HashMap(); for(String key : map.keySet()) {..