wood burning stoves 2.0*
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 Murach's Java Servlets and JSP this week in the Servlets 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: http://aspose.com/file-tools
subject: problem with array of objects
Similar Threads
Programming help
Array doubt
ExamCram Qts
type safe enum
Question on Multidimensional Array