Just because the "Null pointer" message gets printed the last thing in your program does NOT mean that that's when it happened. It just means that SOMEWHERE in your program, there was a null pointer assignment.