Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 13
<p>I'm trying to use an array to deal a Bridge hand and then have it sorted by suits. The program deals all 13 cards, but then I get the error, </p>

<pre><code>"Exception in thread "main" 
java.lang.ArrayIndexOutOfBoundsException: 13 
at DeckStuff.main(DeckStuff.java:29)"
</code></pre>

<p>Any help would be appreciated.</p>

<pre><code>public static void main(String[] args) {

    Card.shuffleDeck();

    Card.dumpCards();

    Card[] bridgeHand = new Card[13];

    for (int i = 0; i &lt; bridgeHand.length; i++) {
        bridgeHand[i] = Card.dealCard();
    }

    for (int i = 0; i &lt; bridgeHand.length; i++) {
        System.out.print(bridgeHand[i]);
    }
    System.out.println();

    Card.sortHand(bridgeHand);

    String[] suit = {"Spades", "Hearts", "Diamonds", "Clubs"};

    int j = 0;
    for(int i = 0; i &lt; 4; i++) {
        String s = suit[i].substring(0,1);
        System.out.print("\n" + s + ": ");

        while (bridgeHand[j].getCardSuitName().equals(suit[i])) {
            System.out.print(bridgeHand[j]);
            j++;
        }
    }   
}
}
</code></pre>
