Уважаемые господа!
task08.task0829 - Модернизация ПО
Никак не могу получить добро от валидатора. И так и этак - не проходит и всё.
Прошу помощи!
package com.javarush.task.task08.task0829;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
/*
Модернизация ПО
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
// List<String> list = new ArrayList<>();
String family = "";
String town = "";
String key = "";
String value = "";
Map<String, String> list = new HashMap<>();
while (true) {
System.out.println("Введи город");
town = reader.readLine();
if (!town.isEmpty()) {
System.out.println("Введи фамилию");
family = reader.readLine();
} else break;
if (family.isEmpty()) break;
// list.put(family,town);
list.put(town, family);
// System.out.println(key + "+" + value);
}
// Read the house number -> town
System.out.println("Введи город для поиска");
town = reader.readLine();
/* for (Map.Entry<String,String> pair : list.entrySet()) {
key = pair.getKey();
value = pair.getValue();
if (value.equals(town)) System.out.println(key);
}*/
if (list.containsKey(town)) System.out.println(list.get(town));
}
}