title: Java ArrayList Deck Class
body: <p>This program is supposed to use ArrayList to create a deck of cards. The user enters how many cards to draw and those cards are printed, then the rest of the cards that are remaining in the deck are printed. I got the user's cards to print but I cant figure out how to get the remaining cards in the deck to print. Any help would be appreciated.</p>
  
  <pre><code>public class Card 
  {
      private int type, value;
      private String[] cardType = {"Clubs", "Spades", "Diamonds", "Hearts"};
      private String[] cardValue = {"Ace", "King", "Queen", "Jack", "10",
                                     "9", "8", "7", "6", "5", "4", "3", "2"};
  
      public Card(int types, int values)
      {
          type = types; 
          value = values;
      }
  
      public String toString()
      {
          String finalCard = cardValue[value] + " of " + cardType[type];
  
          return finalCard;
      }
  
  }
  
  import java.util.Random;
  import java.util.ArrayList;
  
  public class Deck 
  {
      private ArrayList&lt;Card&gt; cards;
  
      public Deck()
      {
          cards = new ArrayList&lt;Card&gt;();
  
          for(int a =0; a&lt;=3; a++)
          {
              for(int b =0; b&lt;=12;b++)
              {
                  cards.add(new Card(a,b));
              }
          }  
      }
  
      public Card drawRandomCard()
      {
          Random generator = new Random();
          int index = generator.nextInt(cards.size());
          return cards.remove(index);
      }
  
      public String toString()
      {
          String result = "Cards remaining in deck: " + cards;
  
          return result;
  
      }    
  }
  
  
  import java.util.Scanner;
  
  public class CardProgram 
  {
      public static void main(String[] args)
      {
          Scanner scan = new Scanner(System.in);
          Card C;
          Deck deck = new Deck();
  
          System.out.println("Enter number of cards to be dealt: ");
          int numberCards = scan.nextInt();
  
          System.out.println("Cards drawn: ");
          for(int i=0; i&lt;numberCards; i++)
          {
              C = deck.drawRandomCard();
              System.out.println(C.toString());
          }
  
          //C = deck.toString();
          //System.out.println(cards.toString());
         // System.out.println(C.toString());
  
  
      }
  
  }
  </code></pre>