• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Null'Pointer'Exception...

 
Vijay Vaddem
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Im sure there is no Pointers in Java...

So, Just wanted to know why the name Null'Pointer'Exception???


:roll:
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there are pointers, you just can't declare them yourself.
 
Vijay Vaddem
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can you give an example over this??


Regards,

Vijay
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're not the first person to be surprised that a language without pointers has something called a NullPointerException.

I don't know for sure, but I'd guess that this is a bit of a misnomer, and that a better name for this type of Exception would probably have been NullReferenceException. (It's too late to change it, now.)
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
References are really pointers to objects.
But where a pointer can be directly manipulated (the dreaded pointer arithmetics in C), references cannot. Because of that no special syntax is needed to dereference them, the runtime environment/compiler/JVM understands that a call to the reference means to address the memory structure in the memory space referenced by the reference and not the raw memory itself.

Small but important distinction.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a recent pontification on this very topic.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic