From the documentation: "An Error
is a subclass of Throwable
that indicates serious problems that a reasonable application should not try to catch." "The class Exception
and its subclasses are a form of Throwable
that indicates conditions that a reasonable application might want to catch."
You *usually* shouldn't do *anything* with Error or any subclass. But, in particular, if you are writing a catch clause and it names Error or a subclass, you are writing an "unreassonable" application.
Programming errors fall into three categories:
1-compilation errors,
2-run-time errors,
3-logical error
Compilation Errors
Compilation errors, also known as compiler errors, are errors that prevent your program from running
Logic Errors
Logic errors are errors that prevent your program from doing what you intended it to do..
Run Time Errors
Run-time errors are errors that occur while your program runs..
and exception are the run time error!
Both Error and Exception are derived from java.lang.Throwable. Errors are those situations that cannot be handled by the JVM and your application cannot potentially recover from Errors.For example, you may run out of system resources, OutOfMemoryError etc. On the other hand exceptions are conditions that occur during the runtime of the application and your (JVM can recover from these conditions and your application can run normally.. For example, ClassCastException, OutOfBoundException, ArithmeticException, IOException.Exceptions are further classified into checked and unchecked exceptions. Please refer to the javadocs for details.