I'm trying to learn more about basic Java and the different types of Throwables, can someone let me know the differences between Exceptions and Errors?
Errors should not be caught or handled (except in the rarest of cases). Exceptions are the bread and butter of exception handling. The Javadoc explains it well:
An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch. Most such errors are abnormal conditions.
Look at a few of the subclasses of
Error, taking some of their JavaDoc comments:
AnnotationFormatError- Thrown when the annotation parser attempts to read an annotation from a class file and determines that the annotation is malformed.
AssertionError- Thrown to indicate that an assertion has failed.
LinkageError- Subclasses of LinkageError indicate that a class has some dependency on another class; however, the latter class has incompatibly changed after the compilation of the former class.
VirtualMachineError- Thrown to indicate that the Java Virtual Machine is broken or has run out of resources necessary for it to continue operating.
There are really three important subcategories of
Error- Something severe enough has gone wrong the most applications should crash rather than try to handle the problem,
RuntimeException) - Very often a programming error such as a
NullPointerExceptionor an illegal argument. Applications can sometimes handle or recover from this
Throwablecategory -- or at least catch it at the Thread's
run()method, log the complaint, and continue running.