码迷,mamicode.com
首页 > 其他好文 > 详细

Checked Uncheckd异常

时间:2017-10-09 17:46:27      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:string   static   www   写代码   指针   col   空指针异常   return   .com   

Checked : 你可以在写代码的时候就throw 或者try catch 的

Unchecked :  Error   + RuntimeException 。提前无法预测的

http://www.cnblogs.com/shihuc/p/5201905.html

NUllpointerException一个例子:不一定要去捕获空指针异常

(2)访问或修改 null 对象的字段。
class Point {
public int x, y;
public int getX() {
return x;
}
}

public class TestNullPointerException {
static Point p1;

public static void main(String args[]){

p1.x = 1; // 此处抛出NullPointerException

}
}

Checked Uncheckd异常

标签:string   static   www   写代码   指针   col   空指针异常   return   .com   

原文地址:http://www.cnblogs.com/x-guozheng/p/7641699.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!