![]() |
VOOZH | about |
The toString() method of the java.lang.Throwable class is used to return a string representation of an exception or error. It is commonly used while printing exceptions to understand what went wrong in a program.
Below example demonstrates how Throwable.toString() provides a concise description of an exception.
java.lang.ArithmeticException: / by zero
Explanation :
public String toString()
Example: This code demonstrates how to use the toString() method of the Throwable class in Java to get a readable description of an exception.
java.lang.NullPointerException
Explanation: