开发者

Why does Java have NullPointerException instead of NullReferenceException? [duplicate]

This question already has answers here: Closed 12 years ago.

Possible Duplicates:

What is a Null Pointer 开发者_开发知识库Exception?

Java: Why aren't NullPointerExceptions called NullReferenceExceptions ?

Our of idle curiosity, does anyone know why the null reference exception in Java was called NullPointerException?

It seems counterintuitive that in a new language that officially has no pointers a choice would be made to use this name when using a null reference.

If anyone can point me to an authoritative explanation, that would be appreciated.


The statement that Java "officially has no pointers" is simply false. Just because you can't do arithmetic on it doesn't mean it's not a pointer. C is not the final authority for programming terminology.

The only people who get hung up over it are either C/C++ fans who want to disparage Java for its lack of power over the bare metal, or (unlikely, nowadays) marketing people who want to sell Java as a simpler, safer alternative to managers who've had bad experiences with C development.

From the Java language specification:

The reference values (often just references) are pointers to these objects, and a special null reference, which refers to no object.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜