title: Creating a Deck of Cards using an ArrayList
body: <p>I know this has been asked by many people before (and I looked around quite a bit before coming here), but I can't seem to figure out how to fix my code.  My task is to make a static makeDeck method that returns an ArrayList containing the 52 cards of a standard deck of cards.  I'm fairly new to ArrayLists, so I'm not entirely sure if I'm initializing my ArrayList makeDeck correctly.  This is what I have so far:</p>
  
  <pre><code>    public class Card 
      { 
        private String mySuit; 
        private int myValue; 
  
        public Card( String suit, int value ) 
        { 
          mySuit = suit; 
          myValue = value; 
        } 
  
        public String name() 
        { 
          String[] cardNames =  
            { 
              "Deuce", "Three", "Four", "Five", 
              "Six", "Seven", "Eight", "Nine", "Ten", 
              "Jack", "Queen", "King", "Ace" 
            }; 
  
          return cardNames[ myValue - 2 ] + " of " + mySuit; 
        } 
      } 
  
      public class MainClass 
      { 
        public static void displayCards( ArrayList&lt;Card&gt; a ) 
        { 
          int i; 
          System.out.println( "Size is " + a.size() ); 
          for ( i = 0 ; i &lt; a.size() ; i++ ) 
          { 
            Card c = a.get( i ); 
            System.out.println( "#" + (i+1) + ": " + c.name() ); 
          } 
        } 
  
      public static ArrayList&lt;Card&gt; makeDeck()
      {
        ArrayList&lt;Card&gt; cards = new ArrayList&lt;Card&gt;();
        String[] cardNames =  
            { 
              "Deuce", "Three", "Four", "Five", 
              "Six", "Seven", "Eight", "Nine", "Ten", 
              "Jack", "Queen", "King", "Ace" 
            }; 
        String[] suits = { "spades", "hearts", "diamonds", "clubs"  }; 
  
              for (int a=0; a&lt;=cardNames.length(); a++)
              {
                  for (int b=0; b&lt;= suits.length(); b++)
                   {
                     cards.add(new Card(cardNames[a], suits[b]));  //I've noticed many people use this to add the card names and suits to the cards ArrayList, and it gives me an error of not being able to turn suits[b] into an integer, so I'm confused as to how it worked for others  
  
                   }
              }
  return cards;
      }
  
      public static void main( String[] args )
      {
        System.out.println(makeDeck());
      }
  </code></pre>
  
  <p>If someone could please help me figure out what I'm doing wrong, I would be very grateful.  Thank you!</p>