Java Throwable printStackTrace() methodThe printStackTrace() method of Java Throwble class is used to print the Throwable along with other details like classname and line number where the exception occurred. SyntaxReturnExample 1Test it NowOutput: java.lang.ArithmeticException: / by zero at ThrowablePrintStackTrace.main(ThrowablePrintStackTrace.java:5) Cause : null Example 2Test it NowOutput: Inside exceptionTest() method java.lang.Exception: Throwing localized message! at ThrowablePrintStackTraceExample2.exceptionTest(ThrowablePrintStackTraceExample2.java:11) at ThrowablePrintStackTraceExample2.main(ThrowablePrintStackTraceExample2.java:4)
Next TopicJava Throwable
|