Переделал задачку, все пункты выполняются, но последнийпункт не засчитывается. Почему?
package com.javarush.task.task08.task0829;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/*
Модернизация ПО
*/
public class Solution {
public static void main(String[] arg) throws IOException {
ArrayList<Person> myList = new ArrayList<>();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
Person namesTable = new Person();
int i = 0;
while (true) {
String city = reader.readLine();
if (city.isEmpty()) {
break;
}
namesTable.setСity(city);
String name = reader.readLine();
namesTable.setName(name);
myList.add(namesTable);
i++;
}
String cityName = reader.readLine();
for (int j = 0; j < myList.size(); j++) {
if (cityName.isEmpty()) {
break;
}
String s = namesTable.getCity();
if (cityName.equals(s)) {
System.out.println(namesTable.getName());
break;
}
}
}
public static class Person {
String name;
String city;
Person(String name, String city) {
this.name = name;
this.city = city;
}
Person() {
}
public String getName() {
return this.name;
}
public String getCity() {
return this.city;
}
public void setName(String name) {
this.name = name;
}
public void setСity(String city) {
this.city = city;
}
}
}