File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes problem with array of objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "problem with array of objects" Watch "problem with array of objects" New topic

problem with array of objects

Simon Gouder

Joined: Nov 08, 2003
Posts: 2
I am havin problems with the following code and have spent already spent hours but got nowhere. can somebody help me pls??
why is all the values in the element objects, equal to the last code entered.
the code is
Scores myScores[] =new Scores[10]; // Scores is class
for(int i =0; i < myScores.length ; i++)
myScores[i] =new Scores();
System.out.print("Score code " + i + " : ");
// keyboard is a class for keyboard input
Simon Gouder

Joined: Nov 08, 2003
Posts: 2
Thanks Charles for the reply. Yes this is an assignment, however I have managed to find the problem. My problem was that setcCode() method sets the value of a member variable within the class whixh was set to static.
I agree. Here's the link:
subject: problem with array of objects
It's not a secret anymore!