だから私はこのコードを持っています:
protected void giveNr(Scanner sc) {
//variable to keep the input
int input = 0;
do {
System.out.println("Please give a number between: " + MIN + " and " + MAX);
//get the input
input = sc.nextInt();
} while(input < MIN || input > MAX);
}
人間が文字や文字列などの整数ではない sth を入力すると、プログラムがクラッシュし、エラーが発生しますInputMismatchException
。間違ったタイプの入力が入力されたときに、人間が再度入力を求められるようにするにはどうすれば修正できますか (プログラムはクラッシュしませんか?)