Последний пункт не проходит. Показывает , что при вводе Лондон вывод Ивановы. BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); Map<String, String> map = new HashMap<String, String>(); String city = reader.readLine(); map.put("Москва", "Ивановы"); map.put("Киев", "Петровы"); map.put("Лондон", "Абрамовичи"); Iterator<Map.Entry<String, String>> iMap = map.entrySet().iterator(); if(!city.isEmpty()){ while(iMap.hasNext()){ Map.Entry<String, String> pair = iMap.next(); if(pair.getKey().equals(city)){ System.out.println(pair.getValue()); } } }