Please, take a look. What may be wrong?
Program works also when I add new number[Enter] at the end of input data. So no data is missing in output.
package pl.codegym.task.task10.task1019;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
/*
Funkcjonalność to nie wszystko!
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
HashMap<String, Integer> map = new HashMap<String, Integer>();
int id = 0;
String imie = null;
while (true) {
String sId = reader.readLine();
if (sId == null)
break;
id = Integer.parseInt(sId);
imie = reader.readLine();
if (imie == null)
break;
map.put(imie, id);
}
if (imie == null)
map.put("", id);
for (Map.Entry<String, Integer> para : map.entrySet()) {
imie = para.getKey();
id = para.getValue();
System.out.println("Id=" + id + " Imię=" + imie);
//System.out.println(id + " " + imie);
}
}
}