Zadanie działa zgodnie z założeniami, ale nie zalicza ostatniego punktu.
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
HashMap<Integer, String> mapa = new HashMap<>();
while (true) {
String sId = reader.readLine();
if (sId.isEmpty()) break;
int id = Integer.parseInt(sId);
String imie = reader.readLine();
if (imie.isEmpty()) {
mapa.put(id, imie);
break;
}
mapa.put(id, imie);
}
for (Map.Entry<Integer, String> para : mapa.entrySet()) {
System.out.println(para.getKey() + " " + para.getValue());
}
}
}
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<Integer, String> mapa = new HashMap<>();
while (true) {
String sId = reader.readLine();
if (sId.isEmpty()) break;
int id = Integer.parseInt(sId);
String imie = reader.readLine();
if (imie.isEmpty()) {
mapa.put(id, imie);
break;
}
mapa.put(id, imie);
}
for (Map.Entry<Integer, String> para : mapa.entrySet()) {
System.out.println(para.getKey() + " " + para.getValue());
}
}
}