Why not the last condition is verifying ?
It says that if an empty string is entered after the number then it must also be displayed
the program is doing so but can't find the error ?
package com.codegym.task.task10.task1019;
import java.io.*;
import java.util.*;
/*
Functionality is not enough!
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
HashMap<Integer,String> map = new HashMap<Integer,String>();
while(true){ //continue the loop
String input1 = reader.readLine();
if (input1.isEmpty()) break;
int number = Integer.parseInt(input1);
String name = reader.readLine();
if (name.isEmpty()) {
map.put(number,name);
break;
}
map.put(number,name);
}
for (Map.Entry me : map.entrySet()) {
System.out.println(me.getKey() + " " + me.getValue());
}
}
}