NEWBIE: Null confusion
Posted on 2006-11-14
I'm getting a null pointer exception on the following:
while ((line = myClass.getString()) != null)
// do stuff
Where myClass.getString returns either a String, or null if no String is available. getString is reading a file, and returning either the next line, or null at EOF. It's processing the last line, returning to the top of the while loop, and then blowing up.
What could be null here? Is it "line", or the evaluation of "(line = myClass.getString()) "? Does it evaluate "line" BEFORE it assigns it the value of getString? (Hmmm.)