Exceptions in Java

Source: Internet
Author: User

Java exceptions are features that we always use in programming, but we rarely pay attention to the details.

Exception architecture

All exceptions are derived to Throwable, and the main 2 inherited classes are exception and error.

We often say that the exception refers to exception,exception divided into check Exception and unchecked Exception.

An error is interpreted in the JDK documentation as a serious problem that indicates that a reasonable application should not attempt to catch, most of which are exception conditions. One of the more special is threaddeath, we should not go to catch this exception, familiar with multithreaded programming friends will definitely know why.

Check Exception and Unchecked Exception

Prior to learning C + + and C #, all exception handling belonged to unchecked Exception, and later learning Java found that the Java language, for some exceptions, forced the requirement to declare methods what exception was thrown, and when it was necessary to force some exceptions to be caught, This exception belongs to the check Exception.

About when should use check Exception, when should use unchecked Exception many people have discussions, and there is no unified conclusion. But the vast majority of the views are: mixed use.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.