I can't pass the last requirement.
package zh.codegym.task.task10.task1019;
import java.io.*;
import java.lang.NullPointerException;
/*
功能还不够!
*/
import java.util.HashMap;
import java.util.Map;
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String ID="";
int id = 0;
String name = "";
ID = reader.readLine();
id = Integer.parseInt(ID);
name = reader.readLine();
HashMap<String,Integer> map=new HashMap<String,Integer>();
while((!ID.isEmpty())&&(!name.isEmpty()))
{
map.put(name,id);
try
{
ID = reader.readLine();
if(!ID.isEmpty())
{
id = Integer.parseInt(ID);
}
}
catch(NullPointerException e)
{
break;
}
name = reader.readLine();
if(!name.isEmpty())
{
}
else
{
map.put("",id);
break;
}
}
for(Map.Entry<String,Integer> pair: map.entrySet())
{
System.out.println(pair.getValue() + " " + pair.getKey());
}
}
}