package exp9; import java.util.Scanner; public class ExceptionTest { public static void main(String[] args) { int[] nums = new int[5]; int size=0; Scanner scan = new Scanner(System.in); while (true) { try { String str = scan.nextLine(); nums[size] = Integer.parseInt(str); size++; } catch (NumberFormatException e) { System.out.println("不接受非整数字符!"); } catch (ArrayIndexOutOfBoundsException e){ System.out.println("数组已满!"); break; } } scan.close(); } }