Output
Variable Name     Value in Memory
n
deck[0]
0
deck[1]
0
deck[2]
0
deck[3]
.
.
.
.
deck[51]
0
0
0
0
0
0.0
0.0
0.0
sum
average
count
  1  public class DeckOfCards {
  2    public static void main(String[] args) {
  3      int[] deck = new int[52];
  4      String[] suits = {"Spades", "Hearts", "Diamonds", "Clubs"};
  5      String[] ranks = {"Ace", "2", "3", "4", "5", "6", "7", "8",
  6        "9", "10", "Jack", "Queen", "King"};
  7          
  8      // Initialize cards
  9      for (int i = 0; i < deck.length; i++)
 10        deck[i] = i;
 11      
 12      // Shuffle the cards
 13      for (int i = 0; i < deck.length; i++) {
 14        // Generate an index randomly
 15        int index = (int)(Math.random() * deck.length);
 16        int temp = deck[i];
 17        deck[i] = deck[index]; 
 18        deck[index] = temp;
 19      }
 20  
 21      // Display the first four cards
 22      for (int i = 0; i < 4; i++) {
 23        String suit = suits[deck[i] / 13];
 24        String rank = ranks[deck[i] % 13];
 25        System.out.println("Card number " + deck[i] + ": " 
 26          + rank + " of " + suit);
 27      }
 28    }
 29  }