请问下面的代码的异常怎么写,跪求大神解答!!!
public void createPlayer() throws Exception {
System.out.println("------------------创建玩家---------------------");
int i=0;
while(i<2) {
System.out.println("请输入第"+(i+1)+"个玩家的id:");
int id =dllx.nextInt();
Players p=player.get(id);
if(p==null) {
System.out.println("请输入名字:");
String name =dllx.next();
Players newplayer= new Players(id,name);
player.put(id, newplayer);
i++;
} else {
System.out.println("你输入的id已被占用,请重新输入!");
continue;
}
}
System.out.println("***欢迎玩家***");
Set<Integer> key= player.keySet();
for (Integer integer : key) {
Players p = player.get(integer);
if(p!=null) {
System.out.println("玩家:"+p.getName());
}
}
}