Sobes.tech
Middle+

Is Throwable a class or an interface?

sobes.tech AI

Answer from AI

In Java, Throwable is a class, not an interface. It is the superclass for all errors and exceptions that can be thrown and caught in a program.

The hierarchy looks like this:

  • Throwable
    • Error (errors that are usually not handled by the application)
    • Exception (exceptions that can be handled)

Example:

try {
    // code that might throw an exception
} catch (Throwable t) {
    // handling any throwable (exception or error)
}