title: java enum to arraylist card deck
body: <p>Problem: only the memory address is out.print of arraylist. For example: Card@14318bb.</p>
  
  <p>I really hope that this is a new question. I've looked and looked and read and learnt, but still seem to have this one in a twist! Code:</p>
  
  <p><em><strong>DeckMain.java</em></strong></p>
  
  <pre><code>public class DeckMain {
      public static void main(String[] args) {
          List&lt;Card&gt; newDeck = new ArrayList&lt;Card&gt;( );
  
          Card.Rank[] ranks = Card.Rank.values();  
          Card.Suit[] suits = Card.Suit.values(); 
  
          for (Card.Suit suit : suits) {
              for (Card.Rank rank : ranks) {
                  newDeck.add(new Card(rank, suit));
              }
          }
  
          int n = newDeck.size();
  
          for (int i = 0; i &lt; n ; i++) {
              System.out.println((i + 1)  + ": " + newDeck.get(i));       
          }
      }
  }
  </code></pre>
  
  <p><em><strong>Card.java</em></strong></p>
  
  <pre><code>public class Card {
      public enum Suit { CLUBS, DIAMONDS, HEARTS, SPADES; }
  
      public enum Rank { TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, 
                         NINE, TEN, JACK, QUEEN, KING, ACE; }
  
      final Rank rank;
      final Suit suit;
  
      public Card (final Rank rank, final Suit suit) {
          this.rank = rank;
          this.suit = suit;
      }
  }    
  </code></pre>