readthefuckingmanual.net

[SOLVED] Uncaught exception java/lang/NullPointerException.

Error added: 2010-10-08T07:24:14Z

0 people waiting for the answer...

1 answers found.

Answer 1533 (0.0% helpful)

Wow. One of the most common errors to get when writing Java code.

It means you're trying to do something on an object that's null.
The code below should create a NullPointerException.

java.util.Vector foo = null;
System.out.println(foo.size());

Look at the line in the stacktrace the error is occuring on.
Either wrap in try { ... } catch ( NullPointerException npe) {...
or use if ( foo != null )....
Permalink

Add an answer/solution

If you know the answer, please add your own solution below.
If you don't know, but find out later, please come back and share your answer - there will be other people struggling with this too.


Please enter 61948 here

If you want to be notified via email when this is solved, enter your email address here: