首页 > 编程语言 > 详细

Exceptions in Java(异常)

时间:2017-12-18 13:32:29      阅读:214      评论:0      收藏:0      [点我收藏+]

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!