public int f() {return Integer 对象}
,如果为 null,自动解箱抛 NPE。数据库的查询结果可能为 null。
集合里的元素即使 isNotEmpty,取出的数据元素也可能为 null。
远程调用对象时,一律要求进行空指针判断,防止 NPE。
对于Session 中获取的数据,建议 NPE 检查,避免空指针。
级联调用 obj.getA().getB().getC();一连串调用,易产生 NPE。
NPE(null point Exception)产生的场景
猜你喜欢
转载自blog.csdn.net/u013310517/article/details/78219861
今日推荐
周排行