- 4
- 0
- 约1.44万字
- 约 50页
- 2019-03-02 发布于浙江
- 举报
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
您可能关注的文档
- 常见电子元件知识介绍.ppt
- 400V低压配电室培训.pptx
- GIS开发实施方案1.pptx
- 常见能源计量测量仪表介绍.ppt
- GPS静态布测技术设计书编写方法.ppt
- 500kV线路保护改造验收标准化作业指导书.doc
- 常用变压器安装与检修.pptx
- 555时基电路与其应用.ppt
- 常用传感器原理与应用 (2).ppt
- 660MW火电机组施工组织设计.doc
- 宣贯培训(2026年)《NYT 4512-2025 非洲菊疫病抗性鉴定技术规程》.pptx
- 宣贯培训(2026年)《NYT 4514-2025木薯副产物综合利用导则》.pptx
- 宣贯培训(2026年)《NYT 4513-2025木薯全程机械化生产技术规范》.pptx
- 宣贯培训(2026年)《NYT 4470-2025全株玉米青贮质量分级》.pptx
- 宣贯培训(2026年)《NYT 4468-2025玉米供需平衡表编制规范》.pptx
- 宣贯培训(2026年)《NYT 4469-2025全株玉米青贮质量评定 综合指数法》.pptx
- 宣贯培训(2026年)《NYT 4474-2025东北地区玉米-大豆轮作生产技术规程》.pptx
- 宣贯培训(2026年)《NYT 4472-2025玉米耐盐碱鉴定评价技术规程》.pptx
- 宣贯培训(2026年)《NYT 4473-2025玉米抗旱性鉴定评价技术规程》.pptx
- 宣贯培训(2026年)《NYT 4478-2025甘薯收获技术规程》.pptx
最近下载
- 2025年新改版苏教版六年级下册科学全册精编知识点(背诵用).pdf
- 2025年国家义务教育质量监测小学四年级德育国测模拟测试题及答案.docx VIP
- 1-砖墙工程量计算表(自动计算).xls
- 【国测德育四年级】小学四年级德育优质均衡监测模拟试卷.docx VIP
- 四年级国测德育模拟试卷一及答案.docx VIP
- 新人教PEP六年级英语上册(全册)同步练习随堂练习一课一练.pdf VIP
- 七十岁驾照换证“三力测试”题库(含答案及解析).docx VIP
- 道路交通控制技术 道路交通控制基础知识 模块一 道路交通控制基础知识.pptx VIP
- 道路交通控制技术配时与性能参数计算一课件.pptx VIP
- 美术社团活动计划.docx VIP
原创力文档

文档评论(0)