[Java] [Exception]

Source: Internet
Author: User

Overview
    • The definition of an exception in Java programming thought : an issue that prevents the current method or scope from continuing to execute .
    • The knowledge points of anomaly are not complicated, the main difficulty lies in the design of exception handling in the process of actual processing.
Classification of exceptions
    • Java exception is divided into error and exception, both of which are subclasses of interface Throwable. Specific relationships such as:
    • which
      • error occurs only in the JVM, and users do not need to capture or throw an error in the program.
      • Exception is divided into the general exception and RuntimeException two major categories.
    • Checked vs Unchecked:
      • Checked: In general, the program can not directly control the external situation, refers to the compile time need to check the class of exception, the user program must try catch or throws. Includes exceptions other than error and runtimeexception and their subclasses
      • Unchecked: Refers to a class of exceptions that do not need to be handled during compilation. No mechanisms such as try catch are required.

Error
    • Error: Used to indicate a serious problem that a reasonable application should not attempt to capture.
    • For example, Virtualmachineerror: This error is thrown when a Java virtual machine crashes or runs out of resources that it needs to continue to operate. This error is given directly to the JVM.
Exception
    • Exception: It points out the conditions that a reasonable application wants to capture.
    • Exception is divided into two categories: one is checkedexception, the other is uncheckedexception (usually called runtimeexception). The difference between the two types of exception is mainly checkedexception need to use try...catch ... The capture is displayed, while the uncheckedexception does not need to be captured.
    • Common Runtimeexcepiton are illegalargumentexception, IllegalStateException, NullPointerException, Indexoutofboundsexception and so on.

[Java] [Exception]

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.