Java-An introduction to exceptions

Source: Internet
Author: User

Java provides exception handling mechanism, can be divided into runtimeexception and checked exception two kinds.

RuntimeException

is a run-time exception that the program itself cannot resolve. For example, for a user to register a Web site, if the current user name is already in use, then the solution can only be the current user with the new user name , and the program itself is not resolved (we can not use the program to delete the original user name, not to him, Then register it with the current user ...).

In enterprise development, the exception of general customization (giving feedback to the user) is biased towards the use of runtimeexception, because the caller of the method does not need to be processed (if there is only one to continue throwing), it is best not to handle it. That's what many people say, Do not capture runtimeexception.

Checked Exception

 Java.io.UnsupportedEncodingException, for example, is usually caused by improper coding of the program, which is entirely to be solved by the program, and is useless to the user.

Java-An introduction to exceptions

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.