Как установить состояние по умолчанию для моей службы aws ecs?

Вы были близки: это отлично работает для меня:

Scanner input = new Scanner(System.in); //construct scanner
while(!input.hasNextInt()) {
    input.next(); // next input is not an int, so consume it and move on
}
int finalInput = input.nextInt();
input.close(); //closing scanner
System.out.println("finalInput: " + finalInput);

Вызывая input.next() в вашем цикле while, вы потребляете нецелое содержимое и повторите попытку, и снова, до следующего input - int.

0
задан Hide 31 December 2018 в 07:53
поделиться