Exceptions in Java(异常)

Posted CaiCongyu

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Exceptions in Java(异常)相关的知识,希望对你有一定的参考价值。

Errors

  An Error is any unexpected result obtained from a program during execution.

  Unhandled errors may manifest themselves as incorrect results or behavior, or as abnormal program termination.

  Errors should be handled by the programmer, to prevent them from reaching the user.

Some common types of program fault

  Logic errors - the program does not match the specification (e.g. the requirements, or design)

  Divide by zero

  Exceeding array bounds

  Using an uninitialised variable/object

  …

Error Handling

  Traditional Error Handling

Return a special value,

  e.g., -1 or EoF

  Shortcoming:

  hard to distinguish different errors

  programmer must remember the meaning of different values

  Have a global error handling routine, and use some form of “jump” instruction to call this routine when an error occurs

  Shortcoming:

  “jump” instruction (GoTo) are considered “bad programming practice”

以上是关于Exceptions in Java(异常)的主要内容,如果未能解决你的问题,请参考以下文章

FOR i IN 1 .. SQL%BULK_EXCEPTIONS.COUNT 如何指向引发异常的集合元素?

sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (2059, "Authentication pl

exceptions-in-java

java异常

exceptions-in-java

Java 中的两种异常(Checked exceptions 和 Unchecked exceptions)