Catching exceptions in Java

Source: Internet
Author: User

Java exception classes are inherited from the Throwable class . Throwable mainly consists of two large categories. The error class and the exception class. The error class exception cannot be caught (it is a JVM exception or thread deadlock). Exception is divided into two types of non-check exceptions (runtimeexception) and check exceptions (non-runtime exceptions).

In Java, if the exception is not handled, the program terminates because of an exception. If a try-catch capture or throws is thrown, the program can be prevented from terminating because of an exception.

The exception is not handled in the. The program terminates after encountering an exception, and the last System.out.println () statement does not get output.

The exception is handled by using Try-catch in the. The program is not terminated because of an exception, but runs to the end. The SYSTEM.OUT.PRINTLN () statement after the catch also gets the output to validate.

Catching 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.