printStackTrace 方法【打印方法栈轨迹】

public class Demo01 {
    
    
    public void method() {
    
    
        int[] arr = new int[2];
        try {
    
    
            int a = arr[5];
        } catch (Exception e) {
    
    
            e.printStackTrace();
        }
    }

    public void method2() {
    
    
        method();
    }

    public static void main(String[] args) {
    
    
        Demo01 d = new Demo01();
        d.method2();
    }
}

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/Mason97/article/details/108431457