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コードの一部です。 3行目にNoElementExceptionが発生しました。 コード全体が必要な場合は、ここでコピーして貼り付け、その内容を説明します。 この例外はどのように解決できますか? ループが始まるたびにキーボード入力を取得したいと思います。NoElementException in java
ありがとうございます。
_Which_3行目、上部、または 'main()'メソッド?あなたの質問を投稿する前に、この問題の助けを借りて、ここを突き刺しましたか? –
'nextInt()'は仕様に従って、 "入力が使い果たされた場合" NoSuchElementExceptionをスローします。標準入力は空でなければなりません。あなたのプログラムの標準入力は何ですか? – bcsb1001