if the uaer type empty name then my program tellla to put(id,null) so i can still display the number as said by the condition but it's not working :(
package com.codegym.task.task10.task1019;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
/*
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<>();
try{
while(true){
int id = Integer.parseInt(reader.readLine());
String name = reader.readLine();
if(name == ""){
map.put(id,null);
break;
}
map.put(id,name);
}
}
catch(NumberFormatException e){
System.out.println(e);
}
for(Map.Entry<Integer,String> pair : map.entrySet()){
System.out.println(pair.getKey()+" "+pair.getValue());
}
}
}