Java program

B

BigSargeone

I'm teaching myself java and trying to enter in one of Barry Burd
program from his book. The varible I'm trying to use is reply and once
I complie and try to excute the project I get an error message
Exception in Thread main java.lang nullpointerexception.
What goning on can anyone help me.

Sargeone
 
A

Andrew Thompson

BigSargeone said:
I'm teaching myself java and trying to enter in one of Barry Burd
program from his book.

I do not have his book.*
..The varible I'm trying to use is reply and once
I complie and try to excute the project I get an error message
Exception in Thread main java.lang nullpointerexception.

No you don't - there is no such error message**.
Please copy/paste compile and runtime errors.
<http://www.physci.org/codes/javafaq.html#exact>

** I recognise what you are trying to say, but that
message has capitals. The Java language is case
sensitive, and so am I.
What goning on can anyone help me.

* So I would need to see the *exact* code you are
using, in order to help further.

Note that a good group for people learning Java is
<http://www.physci.org/codes/javafaq.html#h>

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200704/1
 
R

rossum

I'm teaching myself java and trying to enter in one of Barry Burd
program from his book. The varible I'm trying to use is reply and once
I complie and try to excute the project I get an error message
Exception in Thread main java.lang nullpointerexception.
What goning on can anyone help me.

Sargeone
A null pointer exception very probably means that you are trying to
dereference a null reference. You have created a reference to an
object, but you have not actually created the object the reference is
meant to refer to.

MyObject myob;

At this point you have a null reference - myob. It is null because
you have not yet built the actual object for it to refer to.

myob = new MyObject();

This line creates the object ("new") so your myob reference can now
refer to something.

Look at you code in your debugger. Find the line where the error is
thrown. Check every variable that is used nearby to see which one is
null - that is probably the cause of your problem.

rossum
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top