显示“抵达异常掷出点之前的一连串函数调用过程”到指定的输出目的地。
- public class TestException {
- public static void main(String[] args) {
- TestException te = new TestException();
- te.f1();
- System.out.println("main");
- }
- void f1(){
- f2();
- System.out.println("f1");
- }
- void f2(){
- try{
- f3();
- }catch(Exception e){
- e.printStackTrace();
- }
- System.out.println("f2");
- }
- void f3()throws Exception{
- f4();
- System.out.println("f3");
- }
- void f4()throws Exception{
- f6();
- f5();
- System.out.println("f4");
- }
- void f5() throws Exception{
- throw new Exception();
- }
- void f6(){
- }
- }
- output:
- f2
- f1
- main
- java.lang.Exception
- at TestException.f5(TestException.java:35)
- at TestException.f4(TestException.java:30)
- at TestException.f3(TestException.java:24)
- at TestException.f2(TestException.java:16)
- at TestException.f1(TestException.java:10)
- at TestException.main(TestException.java:5)