-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMapExample.java
More file actions
31 lines (25 loc) · 968 Bytes
/
Copy pathMapExample.java
File metadata and controls
31 lines (25 loc) · 968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package javaExE;
import java.util.Map;
import java.util.HashMap;
public class MapExample {
public static void main(String[] args) {
/* 1. 이름을 키로, 이메일을 값으로 담을 해시맵을 만드세요. */
HashMap<String, String> emails = new HashMap<String, String>();
/* 2. 데이터를 저장하세요 */
/* 3. 해시맵의 크기를 출력하세요. */
System.out.printf("emails.size() -> %d\n", emails.size());
// key 목록 출력
System.out.println("\n== key set ==");
for (String key : emails.keySet()) {
System.out.println(key);
}
// value 목록 출력
System.out.println("\n== values ==");
for (String val : emails.values()) {
System.out.println(val);
}
}
}