📄 rethrowexceptiondemo.java
字号:
// 例 3.2.4 ReThrowExceptionDemo.java
class ReThrowException
{
public void test() throws Exception
{
try
{
throw new IllegalAccessException();
}catch(Exception ne){
System.out.println("Catch Exception in test()");
throw ne; // 再次将异常抛出
}
}
}
class ReThrowExceptionDemo
{
public static void main(String[] args)
{
ReThrowException re = new ReThrowException();
System.out.println("The program begin to run");
try
{
re.test();
}catch(IllegalAccessException ie){
System.out.println("Catch IllegalAccessException:"+ie);
}catch(Exception e){
System.out.println("Catch Exception:"+e);
}finally{
System.out.println("The program is clearing....");
}
System.out.println("The program is over");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -