Iperishing
jsbintask22
2016-10-13 02:45

Scanner中异常: java.util.NoSuchElementException?

5

public void RemoveTest() {
Scanner input = new Scanner(System.in);
System.out.println("Please input Id wanted to delete:");
String idString=null;
while (true) {
idString = input.next();
Student student = map.get(idString);
if (student == null) {
System.out.print("Not exists this student,Please input again:");
continue;
} else {
map.remove(idString);
break;
}
}
input.close();
}

这个方法里面  idString = input.next();一直出现上述错误,Student是我写的一个类,没问题
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

8条回答