- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJavaMap.java
More file actions
Latest commit
26 lines (24 loc) · 714 Bytes
/
Copy pathJavaMap.java
File metadata and controls
26 lines (24 loc) · 714 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
packageDataStructure;
importjava.util.*;
classJavaMap {
publicstaticvoidmain(String[] argh) {
Scannerin = newScanner(System.in);
intn = in.nextInt();
in.nextLine();
HashMap<String, Integer> map = newHashMap<>();
for (inti = 0; i < n; i++) {
Stringname = in.nextLine();
intphone = in.nextInt();
in.nextLine();
map.put(name, phone);
}
while (in.hasNext()) {
Strings = in.nextLine();
if (map.get(s) == null) {
System.out.println("Not found");
} else {
System.out.println(s + "=" + map.get(s));
}
}
}
}