Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

NullPointerException

  Asked By: Gene    Date: Sep 22    Category: Java    Views: 522
  

Can anyone tell me the most common cause(s) of this exception?

Share: 

 

5 Answers Found

 
Answer #1    Answered By: Marta Kim     Answered On: Sep 22

When you call a method on an object that is null..

 
Answer #2    Answered By: Shaun Thomas     Answered On: Sep 22

do I know the Type of Machine................

 
Answer #3    Answered By: Akins Massri     Answered On: Sep 22

I get a NullPointerException and a lot of crap coming
up during runtime and there is not way (as far as I
can see) to get around it. How do I do it?

Please help.

 
Answer #4    Answered By: Sally Pierce     Answered On: Sep 22

> I get a NullPointerException and a lot of crap coming
> up during runtime and there is not way (as far as I
> can see) to get around it. How do I do it?
Without seeing your code nobody can help you with specifics...

What you can do is catch the exception  like this:

void foo (int foobar) // put in YOUR method info...
{
try
{
//your problem code in here
}
catch (Exception e)
{
System.out.println(e);
}
}

Other than that, pin point the location in the code where the error occurs and
post that part...

 
Answer #5    Answered By: Erma Henry     Answered On: Sep 22

A null pointer is just that. It means a class reference is
has a null value meaning it point to nothing eg

import java.util.Date;
....
Date a;
a.toString(); // should generate null pointer

There is no way to get 'around' a null pointer. If you have
done any C/C++ programming you will appreciate the
exception because in C/C++ and other 'lower' languages your
program just shoots itself in the foot.

 
Didn't find what you were looking for? Find more on NullPointerException Or get search suggestion and latest updates.