正在加载图片...
N国■圈回国园E■副 2.1什么是异常 ·早期语言打开文件的程序段·处理异常后的程序段 readFile i int error Code=0 open the file if( theFileOpen )t readFile t determine its size;∥测定文件长度 open the file ∥打开文件 gotEnoughMemory t read the file into memory:∥将文件读入内存; read the file into memory close the file ∥关闭该文件 if( readFailed errorcOde=-1: 1 felse i errorCode=-2; 1 else i errorCode=-3: 1 close the file return error code Java高级程/序投计异常 图君围E翻」Java高级程序设计 异常 2.1 什么是异常 • 早期语言打开文件的程序段 readFile { open the file; // 打开文件 read the file into memory; // 将文件读入内存; close the file; // 关闭该文件; } • 处理异常后的程序段 readFile { int errorCode=0; open the file; if ( theFileOpen ) { determine its size; // 测定文件长度 if ( gotEnoughMemory ) { read the file into memory; if ( readFailed ) { errorCode = -1;} } else { errorCode = -2;} } else { errorCode = -3;} close the file; return errorCode; }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有