Nullpointer Exception
Hi,
think i have missed something at the basic java course :-(
A nullpointer exception is a fault that is caused by something pointing to a referance that is null. Is this correct?
I磎 making a program that is to manage my cd磗. I use a gui as a user inteface. The problem is that i get a nullpointer exception, but my program is working just fine. I have tried everything to make it crash, but it dont. I can cast the exeption away or dont do anything with it, but it cant be good for my program. I am using Eclipse and tried to go in debug mode, but i got [An internal error occurred during: "Debug".]
Dont know why, but....
Do anyone have any tips?
Tes
[696 byte] By [
Tesa] at [2007-9-24]

> A nullpointer exception is a fault that is caused by
> something pointing to a referance that is null. Is
> this correct?
I would say it is caused by attempting to use a reference whose value is null. A reference is either pointing to an object or has the value of null.
> I磎 making a program that is to manage my cd磗. I use
> a gui as a user inteface. The problem is that i get a
> nullpointer exception, but my program is working just
> fine. I have tried everything to make it crash, but
> it dont. I can cast the exeption away or dont do
> anything with it, but it cant be good for my program.
> I am using Eclipse and tried to go in debug mode, but
> i got [An internal error occurred during: "Debug".]
> Dont know why, but....
> Do anyone have any tips?
>
> Tes
Normally, the error displays a stack trace. You can post the stack trace here and perhaps get some ideas.
The stack trace shows the order of methods called, and the specific line number in the source code where the error occurs. If the line number is in your source code, you can look at that line and note all of the reference variables used in the line. One of these must be null. If you insert a System.out.println that shows each variable used in the line, one of those will be null. Then, trace the flow of your program to determine why it is null.