The difference between a run-time exception and a normal exception

Source: Internet
Author: User
Tags terminates

Java provides two types of exception classes, error and exception, which have a common parent class-throwable.

Error indicates that the program has made a very serious error during the run and that the error is not recoverable, such as OutOfMemoryError, Threaddeath, etc.

Exception represents an exception that can be recovered, which the compiler can capture. Consists of two types:

Check for exceptions and Run-time exceptions.

1) Check for exceptions. The Java compiler enforces programs to catch such exceptions, such as IO Exceptions and SQL exceptions.

2 run-time exception. The compiler does not force it to be caught and processed. If no processing occurs, the JVM will handle the exception.

A run-time exception occurs, and the system throws the exception up until the process code is encountered. If no code is processed, it is thrown to the top.

Multithreading and Thread.run () methods are thrown, single-threaded with the main () method. If an exception is not handled, either the thread terminates or the main program terminates once it occurs.

Runtime exceptions include: Nullpointexception (null-pointer exception)

ClassCastException (type conversion exception)

ArrayIndexOutOfBoundsException (array out of bounds exception)

Arraystoreexception (Array store exception)

Bufferoverflowexception (buffer overflow exception)

ArithmeticException (calculation of abnormal transmission)

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.