check exception , runtime exception
来源:互联网 发布:mac 视频特效 编辑:程序博客网 时间:2024/06/10 13:11
Exception 下面除了RuntimeException,其他都属于check异常
RuntimeException(运行时异常)是指因设计或实现方式不当而导致的问题.
说白了,就是程序员造成的,程序员小心谨慎是完全可以避免的异常.比如,事先判断对象是否为null就可以避免NullPointerException异常,事先检查除数不为0就可以避免ArithmeticException异常;
特点:
这种异常Java编译器不会检查它,也就说程序中出现这类异常的时候,即使不处理也没有问题,但是一旦出现异常,程序将异常终止,若采用异常处理,则会被相应的程序执行处理.
public class TestException { public static void div(int a, int b) throws ArithmeticException{ int c = a/b; } public static void main(String[] args) { try{ div(10,0); } catch(ArithmeticException e){ String msg = e.getMessage(); System.out.println(msg); } }}
ArithmeticException本来就属于runtime 异常, 运行时异常编译时不能发现,只能到运行时才能发现,需要用try-catch 来处理。
check异常则是,编译时就发现的,必须程序员自己处理。
阅读全文
0 0
- check exception , runtime exception
- Runtime Exception vs Exception
- runtime exception
- check exception和uncheck exception
- check exception和uncheck exception
- check exception和uncheck exception
- Check Exception or Uncheck Exception
- runtime exception和checked exception
- :runtime exception和checked exception
- runtime exception和checked exception
- check and Unchecked Exception
- 常见的runtime exception
- 常见的 Runtime Exception
- Checked Exception与Runtime Exception 的区别
- 关于runtime exception和checked exception
- runtime exception和checked exception的区别?
- difference-between-unchecked-exception-or-runtime-exception
- runtime exception和checked exception的区别?
- Java面试题
- 石子问题
- Xcode8使用出现 Class PLBuildVersion is implemented in both /Applications/Xcode.app/Contents/Developer/P
- es6学习-2
- [Unity]PureMVC框架解读(下)
- check exception , runtime exception
- c语言---const搭配指针问题
- 从源程序到可执行程序
- 【Python】pip install windows下报ascii无法编码
- JavaWeb项目,使用ajax进行访问Url,依然请求是上个请求地址
- [5] Spring中的AOP操作(使用xml 配置文件的方式)
- leetcode 495. Teemo Attacking
- makefile 工具基本使用(2)
- 顺序表的操作