-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHashMapDicEx.java
More file actions
32 lines (25 loc) · 842 Bytes
/
Copy pathHashMapDicEx.java
File metadata and controls
32 lines (25 loc) · 842 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 generics;
import java.util.*;
public class HashMapDicEx {
public static void main(String[] args) {
HashMap<String, String> dic = new HashMap<String, String>();
dic.put("baby", "아기");
dic.put("love", "사랑");
dic.put("apple", "사과");
Scanner scanner = new Scanner(System.in);
while(true) {
System.out.println("찾고 싶은 단어는?");
String eng = scanner.next();
if (eng.equals("exit")) {
System.out.println("종료합니다...");
break;
}
String kor = dic.get(eng);
if (kor == null)
System.out.println(eng + "는 없는 단어 입니다.");
else
System.out.println(kor);
}
scanner.close();
}
}