I have an array containing all 52 cards in a deck.
ImageIcon[] cards = {aceSpadesIcon, twoSpadesIcon, ... }
Then I shuffle that array
for(int i = 0; i < cards.length; i++)
{
int r = (int)(Math.random()*(i+1));
ImageIcon swap = cards[r];
cards[r] = cards[i];
cards[i] = swap;
}
Now I make four new arrays to fill with the cards array.
ImageIcon[] row1 = new ImageIcon[13];
ImageIcon[] row2 = new ImageIcon[13];
ImageIcon[] row3 = new ImageIcon[13];
ImageIcon[] row4 = new ImageIcon[13];
Now I fill these arrays with the now random cards array
int j = 0;
while(j < cards.length)
{
if(j <= 13)
{
Arrays.fill(row1, cards[j]);
j++;
}
else if(j <= 26)
{
Arrays.fill(row2, cards[j]);
j++;
}
else if(j <= 39)
{
Arrays.fill(row3, cards[j]);
j++;
}
else
{
Arrays.fill(row4, cards[j]);
j++;
}
}
Then I display it in a swing window but I have some errors. I should have 4 rows with 13 diffrent random cards each, but instead I get 4 rows each with 1 random card displayed 13 times. How can I fix my loop so it fills the arrays with different cards?

row1? Could you not simply iterate over the different values as before?