Java reading notes (1)-Exception handling

Source: Internet
Author: User
Tags throw exception

2015-12-31

A . Exception handling

  1. Exception Overview (exception/error)

  2. Exception handling mechanism

    1. Catching exceptions using try{}catch ()

    2. Inheritance system for exception classes ( Small exceptions are handled first , and large exceptions are handled )

    3. Multiple exception captures provided by Java7

    4. Access exception information

    5. Use finally to reclaim resources ( explicitly reclaim physical resources garbage-collected heap memory return System.exit (1))

    6. Nesting of exception handling

    7. java7 Auto-close resource try statement with parentheses )

  3. checked exception and runtime exception system

    1. throws declaration throws exception ( method signature )

  4. Throw an exception with throw

    1. Throw exception ( business logic decision )

    2. custom exception class ( no parameter constructor single parameter string Constructor single parameter throwable constructors super)

    3. catch and throw are used simultaneously ( layered )

    4. Java7 Enhanced throw statement

    5. Exception chain ( exception translation responsibility chain pattern encapsulates the original exception )

  5. Java exception-tracking stack

  6. Exception handling mechanism

    1. Do not over-use exceptions ( efficiency )

    2. Do not use an overly large try block

    3. Avoid using catch all statements

    4. Do not ignore the caught exception

Java reading notes (1)-Exception handling

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.