Java Throwable getCause() methodIt is used to fetch the cause of the Throwable or null if cause can't be determined. This function fetches the cause that was supplied by one of the constructors or that was set after creation with the initCause(Throwable) method. All the PrintStackTrace methods invoke getCause() method to determine the cause of the Throwable. SyntaxReturnIt returns the cause of the Throwable or null if cause can't be determined. Example 1Output: Cause : java.lang.ArithmeticException: / by zero Example 2Output: java.lang.ArithmeticException: / by zero at ExceptionTest.main(ExceptionTest.java:5) Cause : null |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India