Can Java throw an empty reference to an exception?

See the English answer > why can I throw null in Java? 7

try {
    ....
} catch (MyException e){
    /*Can e be null here?*/
}

Since null in Java is a typed null reference, is it possible to input the catch block above as null?

Solution

E will never be empty Even if NULL is thrown somewhere for some reason, e is just a NullPointerException

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>