- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava Map.java
More file actions
Latest commit
29 lines (28 loc) · 738 Bytes
/
Copy pathJava Map.java
File metadata and controls
29 lines (28 loc) · 738 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
//Complete this code or write your own from scratch
importjava.util.*;
importjava.io.*;
classSolution{
publicstaticvoidmain(String []argh)
{
HashMap<String, Integer> hash = newHashMap<String, Integer>();
Scannerin = newScanner(System.in);
intn=in.nextInt();
in.nextLine();
for(inti=0;i<n;i++)
{
Stringname=in.nextLine();
intphone=in.nextInt();
hash.put(name, phone);
in.nextLine();
}
while(in.hasNext())
{
Strings=in.nextLine();
if (hash.containsKey(s)) {
System.out.println(s + "=" + hash.get(s));
} else {
System.out.println("Not found");
}
}
}
}