- 1、本文档共50页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
java语言程序设计-基础篇-课件(第13章)英文
Trace a Program Execution try { statement1; statement2; statement3; } catch(Exception1 ex) { handling ex; } catch(Exception2 ex) { handling ex; throw ex; } finally { finalStatements; } Next statement; * animation statement2 throws an exception of type Exception2. Trace a Program Execution try { statement1; statement2; statement3; } catch(Exception1 ex) { handling ex; } catch(Exception2 ex) { handling ex; throw ex; } finally { finalStatements; } Next statement; * animation Handling exception Trace a Program Execution try { statement1; statement2; statement3; } catch(Exception1 ex) { handling ex; } catch(Exception2 ex) { handling ex; throw ex; } finally { finalStatements; } Next statement; * animation Execute the final block Trace a Program Execution try { statement1; statement2; statement3; } catch(Exception1 ex) { handling ex; } catch(Exception2 ex) { handling ex; throw ex; } finally { finalStatements; } Next statement; * animation Rethrow the exception and control is transferred to the caller Cautions When Using Exceptions Exception handling separates error-handling code from normal programming tasks, thus making programs easier to read and to modify. Be aware, however, that exception handling usually requires more time and resources because it requires instantiating a new exception object, rolling back the call stack, and propagating the errors to the calling methods. * When to Throw Exceptions An exception occurs in a method. If you want the exception to be processed by its caller, you should create an exception object and throw it. If you can handle the exception in the method where it occurs, there is no need to throw it. * When to Use Exceptions When should you use the try-catch block in the code? You should use it to deal with unexpected error conditions. Do not use it to deal with simple, expected situations. For example, the following code * try { System.out.print
您可能关注的文档
- 第三章物业服务费用管理与核算.doc
- 第三章热力学第一定律习题.docx
- 第三章物流功能要素1.doc
- 第三章物态变化检测题(一).doc
- 第三章普通微生物学课后习题及答案2.doc
- 第三章犯罪心理的动态分析.doc
- 第三章电子商务合同法第四章电子签名法.doc
- 第三章流体静力学3.doc
- 第三章社会法学派.doc
- 第三章社会矛盾分析方法.doc
- 护理学相关知识复习测试卷共三套.doc
- 护理学相关知识复习试题含答案(3套).doc
- 2025届高考语文复习:补写句子 课件.pptx
- 气压带和风带对气候的影响(第1课时)(教学设计).docx
- 气压带和风带对气候影响教学设计2024-2025学年高中地理人教版(2019)选择性必修1.docx
- 《故都的秋》课件 2024-2025学年统编版高中语文必修上册.pptx
- 《屈原列传》课件 2024-2025学年统编版高中语文选择性必修中册.pptx
- 《巫溪家乡文化》课件-2024-2025学年高一语文同步备课课件(统编版必修上册).pptx
- 《苏武传》课件 2023-2024学年统编版高中语文选择性必修中册.pptx
- 郑州中控ZKTime8.3 WEB考勤软件培训文档.pptx
文档评论(0)