int selection;
while (true) {
selection = printing();
if (selection == 4) {
id = starting();
if (id < 1 || id > 10) {
if (id == -20150901) {
System.out.println("Exit code entered");
break;
}
id = incorrectId(id);
}
}
}
public static int printing(){
Scanner sc = new Scanner(System.in);
System.out.print("Main menu\n1: check balance\n2: withdraw\n3: deposit\n4: exit\nEnter a choice: ");
System.out.print("Enter a choice: ");
int selection = sc.nextInt();
return selection;
}
이것은 내 Java 코드의 일부입니다. 세 번째 줄에 NoElementException이 발생했습니다. 전체 코드가 필요한 경우 복사하여 여기에 붙여넣고 내용을 설명합니다. 이 예외는 어떻게 해결할 수 있습니까? 루프가 시작될 때마다 키보드 입력을 원합니다.NoElementException in java
감사합니다.
_Which_ 세 번째 줄, 맨 위 또는'main()'방법? 질문을 게시하기 전에이 문제에 대한 도움을 얻기 위해 여기 주변을 찌르셨습니까? –
'nextInt()'는 사양에 따라 "입력이 고갈되면"NoSuchElementException을 던집니다. 표준 입력은 비어 있어야합니다. 프로그램의 표준 입력은 무엇입니까? – bcsb1001