Without seeing your code it's hard to say.

So you've used the 'new' keyword to make an instance of a Student object?
        E.g. Student anna = new Student();

And then you use something like:
        anna.name = "Anna";

If you've done those things then it could be an issue with variable scope perhaps?

On 14/05/2010, at 11:47 PM, JKay wrote:

I keep getting the following error when I run my program:

Exception in thread "main" java.lang.NullPointerException
       at StudentRecordExample.main(StudentRecordExample.java:35)

I looked up what java.lang.NullPointException is in the API and found
this:

"public class NullPointerException
extends RuntimeException

Thrown when an application attempts to use null in a case where an
object is required. These include:

   * Calling the instance method of a null object.
   * Accessing or modifying the field of a null object.
   * Taking the length of null as if it were an array.
   * Accessing or modifying the slots of null as if it were an array.
   * Throwing null as if it were a Throwable value.

Applications should throw instances of this class to indicate other
illegal uses of the null object."

Which as far as I understand means that I'm trying to do something
with a null object. Said object is object anna of class Student, and
the method on the line that is throwing the exception is me attempting
to set the name variable for anna to "Anna"

Any ideas?

James

--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en

--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en

Reply via email to