Максимально приблизил к исходному варианту(когда по номеру дома), но отказывается проходить. Подскажите, что ему нужно...
package com.javarush.task.task08.task0829;
import java.io.*;
import java.util.*;
/*
Модернизация ПО
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
//list of addresses
List<String> gorodall = new ArrayList<String>();
List<String> addresses = new ArrayList<String>();
while (true) {
String family = reader.readLine();
String gorod = reader.readLine();
if (family.isEmpty()) break;
addresses.add(family);
gorodall.add(gorod);
}
String gorodNEW = reader.readLine();
if (gorodNEW != null && !"".equals(gorodNEW)) {
int qwerty=gorodall.indexOf("lol");
System.out.println(addresses.get(qwerty));
}
}
}
/*List<String> familyall = new ArrayList<String>();
List<String> gorodall = new ArrayList<String>();
for(int i=0;i<2;i++) {
String family = reader.readLine();
String gorod = reader.readLine();
familyall.add(family);
gorodall.add(gorod);
}
//String gorodNEW = reader.readLine();
int qwerty=gorodall.indexOf("lol");
System.out.println(familyall.get(qwerty));
//System.out.println("lol");
//i++;
//}
//}
}
}*/