title: How would I create a new object from a class using a for loop in java?
body: <p>I have a class named Card and I have this for loop:</p>
  
  <pre><code>int i;
  for (i = 0; i &lt; 13; i++) {
      Card cardNameHere = new Card();
  }
  </code></pre>
  
  <p>What I want to do is create new instances based on the for loop.  So for example, I would like the names to be card1, card2, card3, etc.  The number would come from the for loop.  </p>
  
  <p>I have tried this and it does not seem to work:</p>
  
  <pre><code>int i;
  for (i = 0; i &lt; 13; i++) {
      Card card[i] = new Card();
  }
  </code></pre>
  
  <p>Can anyone tell me what I am doing wrong?</p>
  
  <p>Thanks.</p>
  
  <hr>
  
  <p>So I am using the solution from Hovercraft Full Of Eels, but I have another problem.</p>
  
  <p>I am using cardList.add(new Card()); , and when I try to use Card(i) to set the name, java won't let me do it. Using it without i works fine, but how do I access it so I can call another method on it such as setId. I would like to call cardName.setId();</p>