Exception handling with a do-while loop in Java

后端 未结 5 644
孤街浪徒
孤街浪徒 2021-01-23 12:43

The algorithm should take in 3 integers to an ArrayList. If the input is not an integer, then there should be a prompt. When I execute my code the catch clause is e

5条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-23 13:32

    You need to move the scanner to the next line. Add this line of code below the error message in the catch section.

    input.nextLine();
    

提交回复
热议问题