Ian He

Results 5 comments of Ian He

![image](https://user-images.githubusercontent.com/16068212/110271161-6d7b0200-8002-11eb-85ae-ad2c8887cf79.png) 提交不了

@huan > ![image](https://user-images.githubusercontent.com/16068212/110271161-6d7b0200-8002-11eb-85ae-ad2c8887cf79.png) > 提交不了 @huan

这个其实是idea的锅,换成白色主题就好了吧

> 选a 这行(Integer) null : Integer.parseInt(s)运行时异常(空指针异常);当parseInt(null)执行时,返回null很正常,但是将null转化成integer对象类型时不对的 null可以转化成Integer对象,但不能转成int,这题报空指针的原因就在这里。

感觉这一题大家都被`(Integer) null`误导了,其实`(Integer) null`是不会报空指针的,真正的原因来自于隐藏的拆箱操作,因为三元表达式前后类型不一致,前面是`Integer`类型,后面是`int`类型,所以这里会先将`(Integer) null`的值拆成`int`类型,把一个`null`赋值给一个`int`类型的变量就会存在空指针。这里如果把三元表达式后面的`parseInt `方法改成`valueOf`方法就没有空指针。