Re: Newbie question re linked list
On Oct 23, 11:10 pm, Lew <l...@lewscanon.com> wrote:
shellri...@hotmail.com wrote:
public class Enrollment {
private Student head;
public Enrollment() {
head = null;
Since head is already null, this assignment has no net effect, except to
potentially waste processor cycles.
--
Lew
Thank you for highlighting that. I will get rid of the assignment. The
good news is that I figured out where I went wrong. In my Student
class, I had made all my variables static, which I understand makes
them available to all instances of the class--is that right? I am
still a bit fuzzy on what static is. I got rid of the static bit and
in my promptRecord method, I have now passed in a reference to a newly
created Student and have used the dot operator to specify which the
changes to the variables of said Student. It seems to be working fine
now. Thanks everybody for trying to help!
public void promptRecord(Student newStudent) throws IOException {
BufferedReader stdin = new BufferedReader(new
InputStreamReader(System.in));
Scanner keyboard = new Scanner(System.in);
System.out.println("\tStudent Details");
System.out.println("\t===============\n");
System.out.println("Student Name: ");
newStudent.student_name = stdin.readLine();
System.out.println("Address: ");
newStudent.address = stdin.readLine();
System.out.println("Age: ");
newStudent.age = keyboard.nextInt();
System.out.println("Outstanding Fees: ");
newStudent.fees_owed = keyboard.nextDouble();
System.out.println("Previous Student? True or False: ");
newStudent.prev_student = keyboard.nextBoolean();
System.out.println("Senior Student? True or False: ");
newStudent.sen_student = keyboard.nextBoolean();
System.out.println("=========================\n");
}