Can someone help - I feel lost - and I don't why the output is in random order ? or if it is something else?
package com.codegym.task.task10.task1019;
import java.io.*;
import java.util.HashMap;
/*
Functionality is not enough!
*/
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<>();
try {
while(true) {
Integer id = Integer.parseInt(reader.readLine());
if (id.equals(null)) {
break;
}
String name = reader.readLine();
if (name.isEmpty()) {
map.put("", id);
break;
}
else {
map.put(name, id);
}
} }
catch (Exception e){
}
for (HashMap.Entry<String, Integer> set : map.entrySet()) {
System.out.println("Id=" + set.getValue() + " Name=" + set.getKey());
}
}
}