Hello I'm getting an error in my code here
what I'm trying to do is output a shuffle of 5 cards e.g 4 of diamonds in red
package javacards; import java.util.Random; public class Deck { private Card[] cards; int i; Deck() { i=5; cards = new Card[52]; int x=0; for (int a=0; a<=12; a++) { for (int b=0; b<=3; b++) { for (int c=0; c<=1; c++) <------- it appears this is the problem but I don't know why /* This is the error I get Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 52 at javacards.Deck.<init>(Deck.java:21) at javacards.TestPoker.main(TestPoker.java:7) */ { cards[x] = new Card(a,b,c); x++; } } } } public Card drawFromDeck() { Random generator = new Random(); int index=0; do { index = generator.nextInt( 52 ); } while (cards[index] == null); i--; Card temp = cards[index]; cards[index]= null; return temp; } public int getTotalCards() { return i; } }