I don't know why output is Rockefeller rather than Gates. Why my for loop choose previous getValue, but not current one. Please, help me.
package com.codegym.task.task08.task0829;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.HashMap;
import java.util.Map;
/*
Software update
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
HashMap<String, String> addresses = new HashMap<>();
while (true) {
String city = reader.readLine();
if (city.isEmpty()) break;
String family = reader.readLine();
addresses.put(city, family);
}
//System.out.println("Enter City name");
String name = reader.readLine();
for (HashMap.Entry<String, String> pair : addresses.entrySet()) {
if (name.equals(pair.getKey()));
{
System.out.println(pair.getValue());
break;
}
}
}
}