Java programming note 12 Exception Handling

Source: Internet
Author: User

1. Exception category:

Error and exception.

Exception is divided into runtime exception and checked exception.

The above differences correspond to the situations

 

2. Try catch and try catch finally related syntaxes and notes for Exception Handling

Only one catch is processed, and finally is always processed, even if return, unless system. Exit ();

 

3. Use and difference of throws and throw (self-designed exceptions)

Why throws? Let the caller handle the exception!

Throws declares that a method has a checked exception, and throw throws an exception in the method. Generally, the two are used together to throw a checked exception in the method and indicate an exception in the method declaration. However, you can also throw a runtime exception in the method, so throws are not required in the method, because the runtime exception does not need to be specially processed.

 

4. Exception and method Rewriting

If a method in the parent class throws an exception, when the subclass inherits the parent class and modifies the method in the parent class, you must pay attention to this problem, the exception classes thrown by the methods rewritten in the subclass must be automatically converted to the exception classes in the parent class. (Included by the exception class in the parent class)

 

Reference: Java se6 comprehensive learning Java getting started and improving

Code omitted

I have actually done a lot of things this week. I have read the code of the recruitment office, read several XML papers, and read object-oriented in Java's comprehensive learning, I also read the above exceptions, container and layout configuration, event processing, and AWT component usage. I just didn't write it out, but I was tired of typing on the keyboard,

Make up for the weekend.

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.