enter code here
`class Rethrow
{
public static void genException()
{
int n[]={4,8,16,32,64,128};
int d[]={2,0,8,0,4};
for(int i=0;i<n.length;i++)
{
try{
System.out.println("n/d is:"+n[i]/d[i]);
}
catch(ArithmeticException exc)
{
System.out.println("Cant Divide By Zero");
throw exc;
}
catch(ArrayIndexOutOfBoundsException exc)
{
System.out.println("No match element found ");
// rethrow the exception
}
}
}
}
class RethrowDemo
{
public static void main(String args[])
{
try
{
Rethrow.genException();
}
catch(ArithmeticException exc) // catch the rethrow Exception
{
// recatch exception
System.out.println("Fatal Error "+"Program Termiated.");
}
}
}
问题1::为什么“RethrowDemo”类的catch会终止“Rethrow”类的catch(Arithmetic Exception)抛出的异常。
问题2::控制权转移如何工作?