Собственно сабж + еще и на null ругается.
package com.javarush.task.task10.task1019;
import java.io.*;
import java.util.HashMap;
/*
Функциональности маловато!
*/
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<>();
HashMap<Integer, String> newMap = new HashMap<>();
int id=0;
String name="";
while (true) {
try {
String t = reader.readLine();
if (t.isEmpty()) break;
id = Integer.parseInt(t);
name = reader.readLine();
if (name.isEmpty()) break;
if (map.containsKey(id)) { // проверяем есть ли в map введеный id, если да, то
String oldValue = map.get(id); // сохраняем старое значение для этого id
newMap.put(id, oldValue); // добавляем в новый список
map.put(id, name);
} else {
map.put(id, name);
}
} catch (Exception e) {
System.out.println(e);
}
}
for (HashMap.Entry<Integer, String> entry : map.entrySet())
System.out.println("Id=" + entry.getKey() + " Name=" + entry.getValue());
for (HashMap.Entry<Integer, String> entry : newMap.entrySet())
System.out.println("Id=" + entry.getKey() + " Name=" + entry.getValue());
}
}