JavaRanch Home    
 
This page:         last edited 19 November 2007         What's Changed?         Edit

Null Pointer Exception   

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)



JavaRanchContact us — Copyright © 1998-2014 Paul Wheaton