- class Demo
- {
- public int div(int a,int b)throws ArithmeticException,ArrayIndexOutOfBoundsException
- {
- int[] arr = new int[a];
- System.out.println(arr[5]);
- return a/b;
- }
- }
- public class ExceptionDemo {
- public static void main(String[] args)
- {
- Demo d = new Demo();
- int x = d.div(6,1);
- System.out.println(x);
- System.out.println("over");
- }
- }
复制代码 主函数没有处理异常为什么也能运行输出结果?
|
|