title: Getting ArrayIndexOutOfBoundsException, array size is determined dynamically
body: <p>In the following code I'm getting ArrayIndexOutOfBoundsException. I'm new to Java don't get the clue that is causing it to go out of bounds. I debug this code and it goes terminated after entering 4 entries. </p>
  
  <pre><code>        String[] suit = {"Clubs", "Diamonds", "Hearts", "Spades"};
          String[] rank = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace"};
          String[] deck = new String[suit.length * rank.length];
  
          int i = (int)(Math.random()*rank.length);
          int j = (int)(Math.random()*suit.length);
  
          System.out.println(rank[i]+" of "+suit[j]);         
  
          for(int k=0; k&lt;suit.length; k++){
              for(int l=0; l&lt;rank.length; l++){
                  //on the following line.
                  deck[rank.length*k + l] = rank[k]+ " of "+suit[l];
              }
          }
  
          for(String s : deck){
              System.out.println(s);
          }
  </code></pre>