- 3
- 0
- 约1.67万字
- 约 17页
- 2017-06-03 发布于湖北
- 举报
JAVA教程 第四讲 Java的例外处理和I/O流4.1 什么是例外 例外就是在程序的运行过程中所发生的异常事件,它中断指令的正常执行。Java中提供了一种独特的处理例外的机制,通过例外来处理程序设计中出现的错误。
4.1.1 例外示例
【例4-1】 import Java.io.*; class ExceptionDemo1{ public static void main( String args[ ] ){ FileInputStream fis = new FileInputStream( text ); int b; while( (b=fis.read())!=-1 ){ System.out.print( b ); } fis.close( ); } } 查看编译结果【例4-2】 class ExceptionDemo2{ public static void main( String args[ ] ){ int a = 0; System.out.println( 5/a ); } } 运行结果
C:\javac Exce
原创力文档

文档评论(0)