title: Adding new objects to an ArrayList in constructor
body: <p>I am trying to add newly created objects to an ArrayList in the constructor of a class. The new objects are being created in another class in the main method.</p>
  <p>Main method:</p>
  <pre><code>public static void main(String[] args) {
      // TODO code application logic here
      Player p1 = new Player(&quot;Peter&quot;);
  }
  </code></pre>
  <p>My Player class:</p>
  <pre><code>public class Player {
  
  protected static int age;
  protected static String name;
  protected static ArrayList players = new ArrayList();
  
  Player(String aName) {
      
      name = aName;
      age = 15;
      players.add(new Player()); // i know this doesn't work but trying along these lines
      
     }
  }
  </code></pre>