-2
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
class Solution {
public static void main(String[] argh) {
Map<String, String> phoneBook = new HashMap<String, String>();
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
sc.nextLine();
for (int i = 0; i < t; i++) {
String name = sc.nextLine();
String phnum = sc.nextLine();
phoneBook.put(name, phnum);
sc.nextLine();
}
System.out.println("Not Found");
while (sc.hasNext()) {
String s = sc.nextLine();
if (phoneBook.get(s) == null)
System.out.println("Not Found");
else
System.out.println(s + "=" + phoneBook.get(s));
sc.nextLine();
}
}
}
Почему вы думаете hasNext не работает? Вы пытались отладить код? – SMA
Просьба уточнить заявление о проблеме, код обмена не помогает нам понять конечную цель. –
hasNext() работает. Любые другие вопросы? –