Null Pointer Exception (Wiki forum at Coderanch) (original) (raw)

The only visible pointer in what's officially a language without pointers, the NullPointerException can lead to much frustration.

NullPointerException is similar to a core dump in C++. It basically refers to a situation where the program expected some object to be present but could not find it.

In other words, the calling object expects the called object to be there, but is suddenly surprised to find that the called object has ditched the calling object and has vanished!

This normally happens due to bad programming/design/programmer's carelessness. Typically beginners (even experienced ones for that matter) tend to make this mistake by not initializing objects properly or not taking care of objects properly, mostly because of the liberty GarbageCollection gives them, thereby giving Java a bad name.

- SathyaSrinivasan (9 Nov 2004).


It should be noted that Java _does_ have pointers. It just doesn't have PointerArithmetic like C and C++. An object reference are essentially pointers to objects. (I should probably find some sources to site for these claims. I'll add them later when I get a chance.)

- LayneLund (12 February 2004)