Java语言程序设计+第六章.pptVIP

  • 2
  • 0
  • 约5.15千字
  • 约 24页
  • 2019-09-06 发布于广东
  • 举报
* * * * public final void call() { System.out.println(哺乳动物会叫。); } * Java面向对象程序设计 第6章 异常 * 本章主要内容 理解异常的概念及其分类 运用 try -catch 块处理异常 运用嵌套 try/catch 块处理异常 运用多重 catch 块处理异常 运用try -catch -finally块处理异常 运用关键字 throw 和 throws 处理异常 自定义异常 * 什么是异常? 异常是Java程序运行过程中所发生的非正常事件,包括两类: Error:JVM系统内部错误、资源耗尽等严重情况,对于这类情况,程序基本上是无能为力。 Exception:其它因编程错误或偶然的外在因素导致的一般性问题,对于这种情况,可以用Java提供的异常处理机制进行处理。例如: 对负数开平方根 空指针访问 试图读取不存在的文件 数据库操作失败 * 异常举例 public class ExceptionTest { public int divide( int num1, int num2) { int result = num1 / num2; return result; } public static void main(String[] args)

文档评论(0)

1亿VIP精品文档

相关文档