title: Can someone please tell me what is wrong with the for loop
body: <p>So I'm supposed to make a deck of cards and I'm doing it in this way.  No CT error but I get IndexOutOfBound Exception.  I dont know why.
  The class Card is already defined.  The value goes up to 12 and the suit goes up to 3, inclusive. Thank you!</p>
  
  <pre><code>ArrayList&lt;Card&gt; deck = new ArrayList&lt;Card&gt; (52);
  
  public StandardDeck()
  {
     buildDeck();
  }
  
  public void buildDeck()
  {
     int index = 0;
     for(int suit = 0; suit &lt;= 3; suit++)
     {
        for(int value = 0; value &lt;= 12; value++)
        {
           deck.set(index, new Card(value, suit)); 
           index++;
        }   
     }
  
  }//buildDeck
  </code></pre>