Thread: an error?
View Single Post
Old Nov 1st, 2006, 12:28 PM   #4
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
NullPointerExceptions occur when a variable has the value "null" when it is not expected. For instance:
java Syntax (Toggle Plain Text)
  1. string myName = null;
  2. int lengthOfMyName = myName.length();
This code will throw a NullPointerException, because you cannot access the length method on a null value.

NullPointerExceptions are a very common error, and some can be very tricky to spot. The only way to diagnose the error is to see the source code. The error stack trace simply doesn't contain enough information to come to a firm conclusion about the cause of the error.
Arevos is offline   Reply With Quote