码迷,mamicode.com
首页 > 编程语言 > 详细

Exceptions in Java(异常)

时间:2017-12-18 14:15:23      阅读:206      评论:0      收藏:0      [点我收藏+]

标签:remember   ini   ble   divide   not   use   occurs   post   sign   

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(异常)

标签:remember   ini   ble   divide   not   use   occurs   post   sign   

原文地址:http://www.cnblogs.com/hahaccy/p/8056963.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!