Java可以引用异常的空引用吗? [英] Can Java throw a null reference to an exception?
本文介绍了Java可以引用异常的空引用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
考虑这个代码:
try {
....
} catch (MyException e){
/*Can e be null here?*/
}
鉴于Java中的 null
是一个类型化的空引用,是否有可能使用 e
作为 null
?
Given that null
in Java is a typed null reference, is it ever possible that the catch block above will be entered with e
as null
?
推荐答案
e
永远不会是 null
。即使 null
由于某种原因被抛出某个地方, e
将只是一个 NullPointerException
。
e
will never be null
. Even if null
gets thrown somewhere for some reason, e
will just be a NullPointerException
.
这篇关于Java可以引用异常的空引用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文