Home> Java> javaTutorial> body text

Briefly describe the java exception handling mechanism

藏色散人
Release: 2020-09-08 10:50:39
Original
19034 people have browsed it

Briefly describe the java exception handling mechanism

For example, if your code is missing a semicolon, the result will be an error java.lang.Error; if you use System.out.println(11/0 ), then because you used 0 as the divisor, a java.lang.ArithmeticException exception will be thrown.

There are many reasons for exceptions, which usually include the following categories:

  • The user entered illegal data.

  • The file to be opened does not exist.

  • The connection is interrupted during network communication, or the JVM memory overflows.

Some of these exceptions are caused by user errors, some are caused by program errors, and others are caused by physical errors. -

To understandHow Java exception handlingworks, you need to master the following three types of exceptions:

Checked exceptions: The most representative checked exceptions are exceptions caused by user errors or problems, which cannot be foreseen by the programmer. For example, when trying to open a file that does not exist, an exception occurs. These exceptions cannot be simply ignored at compile time.

Run-time exceptions: Run-time exceptions are exceptions that may be avoided by the programmer. In contrast to checked exceptions, runtime exceptions can be ignored at compile time.

Error: Error is not an exception, but a problem beyond the control of the programmer. Errors are often ignored in code. For example, when the stack overflows, an error occurs that cannot be checked during compilation.

For detailed Java exception handling content, please click to view: "Java Exception Handling"

The above is the detailed content of Briefly describe the java exception handling mechanism. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!