Arrays and Objects Creation Problem

I'm trying to get this project to work, that records inputed student's names, grades and ID numbers in an array, the have various functions that search for them. Here is the relevant code (the whole class is over 120 lines long):

Scanner in =new Scanner(System.in);

System.out.println("Welcome to the grades program!");

System.out.println("How many students would you like to store grades for?");

int people = in.nextInt();

Student [] students =new Student [people];

for(int i = 0; i < people; i++)

{

in.nextLine();

System.out.println("What is the name of student #" + (i + 1) +" ?");

String studentName = in.nextLine();

System.out.println("What is " + studentName +"'s grade?");

double studentGrade = in.nextDouble();

students [i] =new Student(studentName, studentGrade, (i + 1));

}

for(int i = 0; i < people; i++)

{

System.out.println(students [i]);

}

While student takes in the name, grade, and ID number in its constructor, and has get and set methods for each of the variables, as well as a unique toString() method.

When I go through the printing loop, it only prints the last student enter, so output looks like this:

http://img201.imageshack.us/img201/7197/picture1ev7.png

There is no complier errors.

Any help?

[1931 byte] By [Soy_Saucea] at [2007-11-27 4:44:22]
# 1
I smell some static code in the Student class.Please post the code for the Student class.
cotton.ma at 2007-7-12 9:56:21 > top of Java-index,Java Essentials,New To Java...
# 2

I notice this is your first post, so I'd like to welcome to the Sun Java Forums. I've also noticed that you used code tags on this first post. This is a most uncommon and happy surprise. If I could give you Duke points I would. Thirdly I have found that the code you've posted works fine. I can find no error there. Perhaps, as Cotton notes above, the error is in the Sudent class?

Good luck, and regardless of whether we can help you, let us know how this gets resolved.

/Pete

petes1234a at 2007-7-12 9:56:21 > top of Java-index,Java Essentials,New To Java...