-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathJava Map.java
34 lines (31 loc) · 912 Bytes
/
Java Map.java
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
34
/* *
* Author: Tonmoy Mondal
* URL: https://qinetique.github.io
* */
/*JAVA-15*/
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Solution {
public static void main(String[] argh){
Map<String, Integer> myPhone = new HashMap<>();
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
scanner.nextLine();
for (int i = 0; i < n; i++){
String name = scanner.nextLine();
int phone = scanner.nextInt();
myPhone.put(name,phone);
scanner.nextLine();
}
while (scanner.hasNext()){
String string = scanner.nextLine();
if (myPhone.containsKey(string)){
System.out.println(string + "="+myPhone.get(string));
}
else {
System.out.println("Not found");
}
}
}
}