forked from onlybooks/java-algorithm-interview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMapExample.java
More file actions
16 lines (14 loc) · 447 Bytes
/
MapExample.java
File metadata and controls
16 lines (14 loc) · 447 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package ch04;
import java.util.HashMap;
import java.util.Map;
public class MapExample {
public static void main(String[] args) {
Map<String, Integer> map = new HashMap<>();
map.put("a", 1);
map.put("b", 2);
// Map.Entry로 순회하여 내용 출력
for (Map.Entry<String, Integer> entry : map.entrySet()) {
System.out.println(entry.getKey() + " : " + entry.getValue());
}
}
}