package fiveint; import java.util.InputMismatchException; import java.util.Scanner; public class Five{ public static void main(String[] args) { System.out.println("请输入5个整数,输入0结束:"); int a[]=new int[5]; Scanner put=new Scanner(System.in); try { int n; for(int i=0;(n=put.nextInt())!=0;i++) { a[i]=n; } } catch(InputMismatchException e) { System.out.println("输入有误,请输入整数。"); } catch(ArrayIndexOutOfBoundsException e) { System.out.println("输入有误,请输入5个整数。"); } finally { System.out.println("谢谢使用本程序!"); } } }