-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjavaMap.java
More file actions
36 lines (31 loc) · 794 Bytes
/
javaMap.java
File metadata and controls
36 lines (31 loc) · 794 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
32
33
//Complete this code or write your own from scratch
import java.util.*;
class javaMap{
public static void main(String []argh)
{
Scanner in = new Scanner(System.in);
int n=in.nextInt();
in.nextLine();
HashMap<String,Integer> hashMap=new HashMap<>();
for(int i=0;i<n;i++)
{
String name=in.nextLine();
int phone=in.nextInt();
hashMap.put(name, phone);
in.nextLine();
}
while(in.hasNext())
{
String s=in.nextLine();
if(hashMap.get(s)!=null)
{
System.out.println(s+"="+hashMap.get(s));
}
else
{
System.out.println("Not found");
}
}
in.close();
}
}