Having problems with storing variable in classes
<p>Please see ifmy logic is correct i do not know how to implement what i am trying to do. I am a beginner in java.</p>

<p>Game is a class which stores the Name and the Steps of that user after the game is complete.</p>

<p>[ First Method ]</p>

<pre><code>private game[] gameArray = new game[10];

for(int i = 0; i &lt;gameArray.length;i++){
         gameArray[i].setName(nameTxt.getText());
         gameArray[i].setpSteps(stepsCount);
    }
</code></pre>

<p>By Clicking History Button they will get the previous 10 people's name and steps.</p>

<pre><code>JOptionPane.showMessageDialog(null,
       "Player's Name No. of Steps"+
       "\n"+gameArray[i].toString());
</code></pre>

<p>-The Problem:</p>

<p>1) This code limits to only previous 10 results is there anyway i can get all the previous results</p>

<p>2) This code is not working!</p>

<p>[ Second Method - This is also not working! ]</p>

<pre><code>private game[] gameArray = new game[10];

// Storing the name of player[i]

gameArray[i].setName(nameTxt.getName());

// Storing the number of steps player[i] took.

gameArray[i].setpSteps(stepsCount);

//Displaying previous 10 players name and steps

JOptionPane.showMessageDialog(null,
       "Player's Name No. of Steps"+
       "\n"+gameArray[i].toString());
</code></pre>
