title: How to create a looping shuffle method in an array
body: <p>I am stuck trying to make a deck shuffling method. I searched for answers on Stack Overflow but have not been able to figure it out.</p>
  
  <p>I want to create a shuffle method. This method will pick two random numbers from the array between 0 and the size of the deck. I then want the two numbers to be passed as parameters to my swap() method. I want to create a loop so that the swap method gets called  TIMES_TO_SHUFFLE times. What is the best way to do this?</p>
  
  <p>This is the Deck class.</p>
  
  <pre><code>import java.util.ArrayList;
  
  /**
   * Deck of cards.   
   * @author Stefan
   * @version 2014.11.19
   */
  public class Deck {   
      private ArrayList&lt;Card&gt; deck;
  
      public static final int TIMES_TO_SHUFFLE = 10;
  
      /**
       * Constructor for objects of class Deck
       * Creates a new container for Card objects
       */
      public Deck() {
          deck = new ArrayList&lt;Card&gt;();    
      }
  
      /**
       * Swap two cards that the user chooses.
       */   
      public void swap(int indexA, int indexB) {
          Card temp = deck.get (indexA);
          deck.set(indexA, deck.get (indexB)); 
          deck.set(indexB, temp); 
      }
  
      /**
       * Shuffles two cards by passing parameters to the swapCards method
       */
      private void shuffle() {
  
      }
  
      /**
       * Add a card to the deck.
       * @param Card to be added
       */
      public void addCard(Card cardToAdd) {
          deck.add(cardToAdd);
      }
  
      /**
       * Take the first card from the deck.
       * @return Card or null
       */
      public Card takeCard()  {
          if(deck.isEmpty()) {
              return null; 
          } else {  
          // get the top card
              return deck.remove(0);
          }
      }
  
      /**
       * Show the contents of the deck.
       */
     public void showDeck()  {
          for(Card eachCard : deck) {
              System.out.println(eachCard.getDescription()+ 
              " of " + eachCard.getSuit());
          }
      }
  }
  </code></pre>
  
  <p>This is the Card class.</p>
  
  <pre><code>/**
   * Card class - a typical playing card.
   * 
   * @author Stefan
   * @version 2014.11.18
   */
  public class Card {
      private String suit;
      private int value;
      private String description;
  
      /**
       * @default constructor
       */
      public Card(){
      }
  
      /**
       * Constructor for objects of class Card
       * @param suit e.g. "Hearts"
       * @param value e.g. 10
       * @param description e.g. "Ten"
       */
      public Card(String description, String suit, int value) {
          this.suit           = suit;
          this.value          = value;
          this.description    = description;
      }
  
      /**
       * @return the suit
       */
      public String getSuit() {
          return suit;
      }
  
      /**
       * @param suit the suit to set
       */
      public void setSuit(String suit) {
          this.suit = suit;
      }
  
      /**
       * @return the value
       */
      public int getValue() {
          return value;
      }
  
      /**
       * @param value the value to set
       */
      public void setValue(int value) {
          this.value = value;
      }
  
      /**
       * @return the description
       */
      public String getDescription() {
          return description;
      }
  
      /**
       * @param description the description to set
       */
      public void setDescription(String description) {
          this.description = description;
      }
  
  }
  </code></pre>