for循环中的try catch怎么加

public void GetArray() { // catch error
int[] list = new int[Size];
System.out.println("Enter " + Size + " integers of the array:");
for (int i = 0; i < Size; i++) {
int a = i + 1;
System.out.println("Enter integer" + a + ":");
input = new Scanner(System.in);
int Input = input.nextInt();
list[i] = Input;
}
用try catch处理:当输入不为int类型时,如何重做当前循环

不想写代码,可以这样做,改用while循环或者去掉for中的i++,然后再循环体里面加try catch finally就可以了如果还是不懂再追问我
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答