Cual es el error en el siguiente código por favor:
public class Arreglos
{
public static void main(String[] args)
{
String[] suit = {"Clubs", "Diamonds", "Hearts", "Spades"};
String[] rank = {"2", "3","4","5","6","7","8","9","10", "Jack","Quenn","King","Ace"};
int x=(int)(Math.random()*rank.length);
int y=(int)(Math.random()*suit.length);
System.out.println(rank[x]+" of "+suit[y]);
String[] deck = new String[suit.length*rank.length];
for(int i=0; i<suit.length; i++)
for(int j=0; j<rank.length; j++)
{
deck[rank.length*i+j] = rank[i] + " of " +suit[j];
System.out.println(deck[rank.length * i + j]);
}
}
}
Al ejecutarlo obtengo el siguiente error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4
at Arreglos.main(Arreglos.java:15)