14

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.

Community
  • 1
  • 1
Uri
  • 88,451
  • 51
  • 221
  • 321
  • Entertainingly, you commented last year on the question in Jsight's link. =) – Riggy Jan 10 '11 at 15:50
  • @Riggy: Ugh, my bad. I did the wrong search (java NullPointerException) instead of (java NullReferenException). I'm deleting the question to relinquish any ill-gotten rep. – Uri Jan 10 '11 at 16:03

1 Answers1

5

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.

Michael Borgwardt
  • 342,105
  • 78
  • 482
  • 720
  • 3
    The disagreement on names of generally well-understood concepts is a fundamental problem across the entire computer science discipline. What's worse is a disagreement on names within a single language specification. What's the point of having two different words to refer to the same thing? Why do they need to tell us it's a pointer? To say that it's as efficient as a C/C++ pointer? In that case, they should've been aware of this naming discrepancy. – oleks Nov 22 '12 at 07:00