Re: NullPointerException
Jack wrote, quoted or indirectly quoted someone who said :
Does java [sic] NullPointerException always cause crash?
According to Roedy Green :
Thomas Pornin wrote:
Theoretically you are right. However I did encounter JVM implementations
which occasionally had trouble with NullPointerException (including a
port of Sun's JVM for FreeBSD).
Come on, guys, Jcheeze! The OP clearly meant crash of his program, not the JVM.
The answer is that uncaught exceptions will cause termination of a program.
Ones you catch and deal with properly will not.
'NullPointerException', or "NPE" as some abbreviate it, is a runtime
exception, that is, it is a subtype of 'RuntimeException'. Runtime exceptions
generally represent a programmer mistake. A properly-written program will not
throw an NPE.
Runtime exceptions are designed not to be caught, but to cause a program to
abort. It is not usual (nor, in my opinion, usually correct) to handle
runtime exceptions routinely. All such should be prevented, not handled. If
you want to insist that an exception be caught and handled, use a checked
exception, one that is a subtype of 'Exception' but not 'RuntimeException'.
Read the tutorials on java.sun.com and other introductory material on
exceptions for more information.
--
Lew