Java Throwable getStackTrace() methodLast Updated : 17 Mar 2025 The getStackTrace() method of Java Throwable class is used to return an array of StackTraceElement given by printStackTrace() method. Some virtual machines may omit one or more frames from the stack trace. SyntaxReturnAn array of StackTraceElement as given by printStackTrace. Example 1Output: class java.lang.StackTraceElement main ThrowableGetStackTraceExample1.java ThrowableGetStackTraceExample1.main(ThrowableGetStackTraceExample1.java:4) 4 Example 2Output: Caught inside Main: ThrowableGetStackTraceExample2.function2(ThrowableGetStackTraceExample2.java:10) ThrowableGetStackTraceExample2.main(ThrowableGetStackTraceExample2.java:15) Next TopicJava-throwable-getsuppressed-method |
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India