If you look up the documentation of the java.lang package API, you will discover that the package contains almost three dozen exception classes and a couple of dozen error classes. Both groups extend the java.lang.Throwable class, inherit all the methods from it, and do not add other methods. The most often used methods of the java.lang.Throwable class are the following:
- void printStackTrace(): Outputs the stack trace (stack frames) of the method calls
- StackTraceElement[] getStackTrace(): Returns the same information as printStackTrace(), but allows programmatic access of any frame of the stack trace
- String getMessage(): Retrieves the message that often contains a user-friendly explanation of the reason for the exception or error
- Throwable getCause(): Retrieves an optional object of java.lang.Throwable that was the original reason for the exception...