- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Chapter 17 Exceptions and Assertions.ppt
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved. 0-13-222158-6 Chapter 17 Exceptions and Assertions Objectives To know what is exception and what is exception handling (§17.2). To distinguish exception types: Error (fatal) vs. Exception (non-fatal), and checked vs. uncheck exceptions (§17.2). To declare exceptions in the method header (§17.3). To throw exceptions out of a method (§17.3). To write a try-catch block to handle exceptions (§17.3). To explain how an exception is propagated (§17.3). To rethrow exceptions in a try-catch block (§17.4). To use the finally clause in a try-catch block (§17.5). To know when to use exceptions (§17.6). To declare custom exception classes (§17.7 Optional). To apply assertions to help ensure program correctness (§17.8). Syntax Errors, Runtime Errors, and Logic Errors You learned that there are three categories of errors: syntax errors, runtime errors, and logic errors. Syntax errors arise because the rules of the language have not been followed. They are detected by the compiler. Runtime errors occur while the program is running if the environment detects an operation that is impossible to carry out. Logic errors occur when a program doesnt perform the way it was intended to. Runtime Errors Catch Runtime Errors Exception Classes System Errors Exceptions Runtime Exceptions Checked Exceptions vs. Unchecked Exceptions Unchecked Exceptions Checked or Unchecked Exceptions Declaring, Throwing, and Catching Exceptions Declaring Exceptions Every method must state the types of checked exceptions it might throw. This is known as declaring exceptions. public void myMethod() throws IOException public void myMethod() throws IOException, OtherException Throwing Exceptions When the program detects an error, the program can create an instance of an appropriate exception type and throw it. This is known as throwing an exception. Here is an example, throw new TheException();
您可能关注的文档
- A Case of Recurrent Anaphylaxis.ppt
- A Comparative Study of East Asia and India.ppt
- A Discussion of the Insider Threat.ppt
- A Guide to Getting Published.ppt
- A Levels 家长及学生讲座讲义-Edexcel Update August 2013.ppt
- A Recovery-Friendly, Self-Managing Session State Store.ppt
- A Taste of Technology.ppt
- A women's world, a better world.ppt
- A Workflow Approach to Designed Reservoir Study.ppt
- AARP Tax-Aide Regional MeetingsOctober 2010.ppt
- 2024年贵州贵州省文化旅游科技有限公司真题及答案详解(典优).docx
- 2024年贵州省粮食储备集团有限公司招聘笔试真题精编答案详解.docx
- 2024江苏盐城市交通投资建设控股集团有限公司招聘招聘笔试备考试题(含答案详解).docx
- 2024年莆田市数字集团有限公司招聘真题含答案详解(最新).docx
- 2024年贵州贵州省旅游产业发展集团有限公司招聘真题附答案详解(名师推荐).docx
- 2024年莆田市数字集团有限公司招聘真题附答案详解(夺分金卷).docx
- 2025中国诚通控股集团有限公司社会招聘2人笔试备考题库及完整答案详解1套.docx
- 2024年菏泽郓城县产业投资发展集团有限公司招聘真题有答案详解.docx
- 2024年贵州贵州贵安发展集团有限公司招聘真题附答案详解(夺分金卷).docx
- 2024年贵州贵州省文化旅游科技有限公司真题含答案详解(培优b卷).docx
最近下载
- 小学生安全教育课件预防性侵害.pptx VIP
- 1.1 描述位置(教学课件)科学冀人版二年级上册.ppt
- 小学科学 科学开学第一课 .pptx VIP
- 基坑监测方案.pdf VIP
- 湘教版七年级上册地理全套教案(最全).doc
- 2025-2026学年湘鲁版(2024)小学英语四年级上册(全册)教学设计(附目录).docx
- 新北师大版七年级上册数学全册课件(2024年秋季新版教材).pptx
- 中华人民共和国计量法培训.ppt VIP
- 2.1 乘法的意义(课件)2025-2026学年度冀教版数学二年级上册.pptx VIP
- 2025年北京市公务员考试行测试卷历年真题及答案详解(历年真题).docx VIP
文档评论(0)