title: Trying to create an Array of Objects
body: <p>I have an object I am trying to put in an array list:</p>
  
  <pre><code>class PlayerScores {
  
  String playerName;
  int played=0;
  int win=0;
  int draw=0;
  int loss=0;
  int points=0;
  
  
  void playerNameSet(String name){
      playerName=name;
  }
  void played(){
      played=played+1;
  }
  void win(){
      win=win+1;
      points();
  }
  void draw(){
      draw=draw+1;
      points();
  }
  void loss(){
      loss=loss+1;
  }
  
  void points(){
      points = (win*3)+draw;
  }
  
  }
  </code></pre>
  
  <p>and basically, when the user has chose how many players there are I want to initialize an Array of these objects but I am getting errors. Here is the code for initializing the array and then assigning names to the players as well.</p>
  
  <p>the array has been defined at the begining of my code and is public so I can use it in different activities: 
      "PlayerScores[] playersObjects;"</p>
  
  <pre><code>public PlayerScores[] makePlayerObjects() {
          playersObjects = new PlayerScores[players];
          for(int i = 0; i &lt; players + 1; i++)
          {
              playersObjects[i].playerNameSet(name variable);
          }
  
      return playersObjects;
  }
  </code></pre>
  
  <p>the error seems occur on the line where the name is being set but it is not to do with the name variable.</p>
  
  <p>Any help would be massively appreciated, 
  Thanks, Oli</p>