You are viewing a single comment's thread. Return to all comments →
BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); HashMap<String, String> phoneBook = new HashMap<>(); try { int n = Integer.parseInt(in.readLine()); while (n-- > 0) phoneBook.put(in.readLine(), in.readLine()); String key; while ((key = in.readLine()) != null) { if (phoneBook.containsKey(key)) { System.out.println(key + "=" + phoneBook.get(key)); } else { System.out.println("Not found"); } } in.close(); } catch (Exception e) { System.out.println(e); }
Seems like cookies are disabled on this browser, please enable them to open this website
Java Map
You are viewing a single comment's thread. Return to all comments →