代码的相关部分:
Scanner kbd = new Scanner(System.in); //to get user input
while(!close) { //program will keep prompting user for selection until they close it
System.out.println(menu); //prints the menu
selection = kbd.nextLine(); //gets the menu selection from the user
这仅在从方法调用返回while循环时发生,如果我从不带方法调用的if语句返回则不会发生错误。这是完整的错误消息:
Exception in thread "main" java.util.NoSuchElementException: No line found
at java.util.Scanner.nextLine(Unknown Source)
at class.main(class.java:29)
它指向的selection = kbd.nextLine();
线是线。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句