Throwable.getStackTrace() has the following syntax.
public StackTraceElement [] getStackTrace()
In the following code shows how to use Throwable.getStackTrace() method.
public class Main { public static void main(String[] argv) { Throwable t = new Exception("from java2s.com"); /*from ww w .j a va 2 s .com*/ System.out.println(t.getStackTrace()); } }
The code above generates the following result.