public class Demo {

    public static void main(String[] args) {
        Demo demo = new Demo();
        demo.go();
    }
    
    public void go(){
        StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
        for(StackTraceElement s : stackTrace){
            System.out.println("类名:" + s.getClassName() + "  ,  java文件名:" + s.getFileName() + ",  当前方法名字:" + s.getMethodName() + ""
                    + " , 当前代码是第几行:" + s.getLineNumber() + ", " );
        }
    }
    
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-22
  • 2022-12-23
  • 2022-02-24
  • 2021-08-01
  • 2022-12-23
  • 2022-03-07
猜你喜欢
  • 2022-12-23
  • 2022-02-11
  • 2021-09-27
  • 2022-12-23
  • 2021-06-11
  • 2022-12-23
相关资源
相似解决方案