title: Java: using get method with an array
body: <p>I was hoping someone would be able to give me some help with the correct way of returning an array with a get method.</p>
  
  <pre><code>public void setScores (int Scores[])
  {
      this.scores = Scores;
  }
  </code></pre>
  
  <p>I can set the Array no problem, I can't figure out a way to return the array to print.</p>
  
  <pre><code>public int [] getScores ()
  {
  
      for (int index =0; index &lt;5; index ++)
      {
          System.out.println("Score"+x +"is" +this.scores[index]);
          x=x+1;
      }
      return scores;
  }
  </code></pre>
  
  <p>I know the above code will <strong>not</strong> work because I am simply returning the whole array, not the elements within it. </p>
  
  <p>What I am trying to do is, display each element of the array to console:</p>
  
  <pre><code>System.out.println( "Player "+playName+"'s Scores are: \n"+Players.getScores());
  </code></pre>
  
  <p>Do I need to use a for loop on the above part?</p>
  
  <p>Appreciate the help, 
  thanks</p>