📄 exceptiondemo8.java
字号:
public class ExceptionDemo8{
public static void functionC() throws Exception{
System.out.println("进入函数C");
throw new Exception("异常测试");
}
public static void functionB() throws Exception{
System.out.println("进入函数B");
try{
functionC();
}catch(Exception e){
e.printStackTrace();
throw e;
}
System.out.println("退出函数B");
}
public static void functionA() throws Exception{
System.out.println("进入函数A");
try{
functionB();
System.out.println("退出函数A");
}catch(Exception e){
System.out.println("函数A调用函数B时,捕获异常,抛出新的异常");
throw new Exception("函数A定义的新异常");
}
}
public static void main(String arg[]){
System.out.println("进入主函数main");
try{
functionA();
}catch(Exception e){
System.out.println("函数main调用函数A时,捕获异常");
e.printStackTrace();
}
System.out.println("退出主函数main");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -