北京大学JAVA讲义__第 4 章 异常.pptVIP

  • 1
  • 0
  • 约8.9千字
  • 约 36页
  • 2018-06-01 发布于河南
  • 举报
北京大学JAVA讲义__第 4 章 异常.ppt

哈尔滨工业大学计算机系代亚非 第 4 章 异常 北京大学计算机系 代亚非 第4章 异常 4.1 异常的概念 4.2 异常的分类 4.3 捕获异常 4.4 声明异常 4.5 抛出异常 4.6 创造自己的异常 4.7 总结 4.1 异常的概念 什么是异常? 异常实际上是程序中错误导致中断了正常的指令流的一种事件. 没有处理错误的程序: read-file { openTheFile; determine its size; allocate that much memory; closeTheFile; } 4.1 异常的概念 以常规方法处理错误 openFiles; if (theFilesOpen) { determine the lenth of the file; if (gotTheFileLength){ allocate that much memory; if (gotEnoughMemory) { read the file into memory; if (readFailed) errorCode=-1; else errorCode=-2; }else errorCode=-3; }else e

文档评论(0)

1亿VIP精品文档

相关文档