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?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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:
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
Throwable: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 aNullPointerExceptionor an illegal argument. Applications can sometimes handle or recover from thisThrowablecategory — or at least catch it at the Thread’srun()method, log the complaint, and continue running.FileNotFoundExceptionandTimeoutException…