Exceptions in Java

Source: Internet
Author: User

1. What is an exception

what is an exception

Terminal the event of normal instruction flow

errors generated by the program during operation are called exceptions.

syntactically correct error in operation

2. Classification of exceptions

The virtual opportunity generates an exception object when the program generates an exception

all of the exception classes are sub-class of Throw ble

exceptions are divided into two main categories:

ERRor: Error, which occurs when the virtual machine is running, and when an error occurs, the virtual machine shuts down directly

Exception: Exception

Exception are divided into two main categories:

run-time exception Runtimeexception(uncheck exception)

Compile-time exception (Check exception)

If check exception is likely to occur in a piece of code , then the Java compiler will force the code to be handled abnormally.

For example: ThRead.sleep (+);

3.try.How to use the catch.finally structure

try{

Put code that might have an exception

}catch (Exception e) {

e.printstacktrace ();

}finally{

regardless of whether an exception occurs, it will be executed

}

Exceptions in Java

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.