Hi,

StudentRecord object is the same as the lab exercise so I don't think its a
problem with this class.

I thinks its my Student class which I have as follows:

public class Student {    
    // Constructor to initialize student
    public Student() {
    }

    // Declare instance variables.
    public StudentRecord studentRecord;
    private Integer studentId;

    // Declare static variables.
    private static int studentCount = 0;
    /**
     * Returns the number of instances of StudentRecords
     */
    public static int getStudentCount(){
        return studentCount;
    }

    /**
     * Increases the number of instances of StudentRecords.
     * This is a static method.
     */
    public static void increaseStudentCount(){
        studentCount++;
    }

    /**
     * Returns the Student Id
     */
    public int getStudentId(){
        return studentId;
    }
    
    /**
     * Sets the student Id
     */
    public void setStudentId(int studentId) {
        this.studentId = studentId;
    }

}

Thanks for your help,
Brian

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of * ^ *
Sent: 23 March 2009 19:40
To: Free Java Programming Online Training Course By Sang Shin
Subject: [java programming] Re: Homework for 1014


On Mar 22, 7:11 am, "Brian Martin" <[email protected]> wrote:
> Hi,
>
> I have seen this question asked before but can't see the answer on this
> forum.
>
> I have created the student record, student, and my own project main as
> requested.
>
> When attempting to run the code I get an error Exception in thread "main"
> java.lang.NullPointerException
>
> at the following line where I attempt to set a student name :
> annaStudent.studentRecord.setName("Anna");
>
> I think this may be something to do with how the Student class has been
> created so if you need a copy of my student class please let me know.
It could either be the student or studentRecord object. Why don't you
paste relevant code fragments here, where we can provide input for
collective benefit. Cheers.
>
> Thanks for any help.
>
> Brian



--~--~---------~--~----~------------~-------~--~----~
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