-
java异常处理
3.8 异常处理
什么是异常
知道Java异常分类
处理异常的两种方式
throw和throws区别
如何创建自定义异常
概念:
在程序中,可能产生程序员没有预料到的各种错误情况,比如打开一个不存在的文件等,在Java中,这种在程序运行时可能出现的错误称为异常。
异常可以把“描述在正常执行过程中做什么事”的代码和“出了问题怎么办”的代码相分离
例子:demo05.ExceptionDemo.java
Java异常分类A:
java.lang.Error,java.lang.Exception
Error(错误):jvm系统内部错误、资源耗尽等严重问题,发生Error时,编程人员无能 为力,只能终止程序,例如内存溢出等。
Exception(异常):因编程错误或偶然的外在因素导致的一般性问题,例如:对负数 开平方根、空指针访问等,当发生Exception 时,编程人员可以做出处理,并做出人性 化响应,比如弹出窗口,显示“请不要输入负数!”。
异常分类B:
检查性异常:编译器必须处理的异常,该类异常通常是Exception类型或其子类(RuntimeException类除外)//运行时异常
SQLException、IOException、ClassNotFoundException
例子:/DemoProject/src/com/hyg/demo08/FileInputStreamDemo.java
非检查性异常:编译器不要求强制处理的异常,RuntimeException类及其所有子类都是非检查性异常。
NullPointerException、ClassCastException
例子:equa
- 2022-02-14 14:02:16下载
- 积分:1
-
给定一块宽度为W的矩形板,矩形板的高度不受限制。现需要从板上分别切割出n个高度为hi,宽度为wi的矩形零件。切割的规则是零件的高度方向与矩形板的高度方向保持一致...
给定一块宽度为W的矩形板,矩形板的高度不受限制。现需要从板上分别切割出n个高度为hi,宽度为wi的矩形零件。切割的规则是零件的高度方向与矩形板的高度方向保持一致。问如何切割使得所使用的矩形板的高度h最小?递归分治,刚才上传的ex1.rar有错,以这个为准.-Given a width W of the rectangular plate, rectangular plate of height restrictions. Is the need to cut out from the board, respectively, n-height hi, a width of the rectangular parts wi. Parts of the rules of cutting height direction and the direction of rectangular plates with a high degree of consistency. Asked how to make the use of cutting rectangular plate of height h the smallest? Recursive sub-rule, has just uploaded ex1.rar wrong, this shall prevail.
- 2022-09-10 18:50:03下载
- 积分:1
-
按任意角度旋转图片,并生成新的旋转后图片
按任意角度旋转图片,并生成新的旋转后图片-?
- 2022-03-16 22:35:35下载
- 积分:1
-
软件实现硬盘写保护卡
软件实现硬盘写保护卡-software write protect drive
- 2022-05-28 13:28:17下载
- 积分:1
-
Grid控件的实现,表格形式显示的界面的实现的源程序
Grid控件的实现,表格形式显示的界面的实现的源程序-Grid Ctrl
- 2022-03-03 11:26:19下载
- 积分:1
-
Manual of SGM Color LAB
Manual of SGM Color LAB
- 2022-03-11 21:43:57下载
- 积分:1
-
personal curriculum design source. Including a hefty almanac, a UFO C game. Stud...
个人的课程设计源码.包括一个万年历,一个UFO的C游戏程序.还有学生管理系统..全是C的-personal curriculum design source. Including a hefty almanac, a UFO C game. Students in the management of the entire system .. C
- 2022-04-29 07:25:30下载
- 积分:1
-
拥塞DES的车
应用背景kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh klllllllllllllllllllllllllllllllllllllmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm关键技术kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
- 2023-01-15 16:55:03下载
- 积分:1
-
colorMoment
在图像识别的时候用到的颜色矩特征的提取算法 是用C++实现的-Color moment feature extraction algorithm is used when the image recognition using C++
- 2022-05-13 05:30:02下载
- 积分:1
-
经典游戏doom的代码,学习C编程的好
经典游戏doom的代码,学习C编程的好-Classic doom games of the code, learn good C programming
- 2022-08-16 03:10:10下载
- 积分:1