Using Java to implement object-oriented fifth chapter

Source: Internet
Author: User
Tags try catch
The fifth chapter anomaly one, exception overview

Overview: Exceptions are abnormal events that occur during a program's run, and he interrupts a running program

Second, exception handling

1. Keyword: Try Catch finally throw throws

2.Try: Put the code that might appear to be abnormal in the Try

3.Catch: Catching exceptions

4.Finally: Code that executes regardless of whether there is an exception

5.Throw: Always appear in the method body

6.Throws: Always appears in the declaration of the method, using the various exceptions that indicate that the modification method may be thrown

Three: Common exceptions

Exception: Root class for exception hierarchies

ArithmeticException: The case of arithmetic error,

ArrayIndexOutOfBoundsException: Array greater than or less than the size of the actual array

NullPointerException: Attempting to access a null object member

ClassNotFoundException: To get the data type mismatch with the actual input type

IllegalArgumentException: Illegal parameters accepted by method

Four: log4i Record day file information

The log file has an output priority:

From high to Low: Error warn info debug

Using Java to implement object-oriented fifth chapter

Related Article

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.