When debugging java code, sometimes it's important to know where you come from. So you can print current stack trace to help you.
1. new Exception().printStackTrace();
2. Thread.currentThread().getStackTrace(); This returns an array of StackTraceElement that represents current stack of your program.
本文介绍了两种在Java中打印当前堆栈跟踪的方法:通过创建一个新的Exception实例并调用其printStackTrace()方法;或者使用Thread.currentThread().getStackTrace()来获取表示程序当前堆栈的StackTraceElement数组。
883

被折叠的 条评论
为什么被折叠?



