class Try_Catch_Exp1
{
public static void main(String[] args)
{
int d=0,a;
try
{
System.out.println("Before throw Exception");
a=5/d;
System.out.println("the Exception is throw,The statement is't run");
}
catch(ArithmeticException e)
{
System.out.println("处理算数异常的catch语句块捕获了异常!");
System.out.println("捕获的异常为"+e);
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println("处理数组下标越异常的catch语句块捕获了异常!");
System.out.println("捕获的异常为"+e);
}
finally
{
System.out.println("这是所有catch块的共有部分!");
}
System.out.println("try-catch-finally块后面的语句");
}
}
|
|