Help removing items from an Arraylist and placing into a 2D Array
I need to remove 52 RANDOM elements from my arraylist and place them into a 2D array with 6 rows and 9 columns. This is my code so far.
Code:
private Shoe[][] getRandomShoesArray() {
ArrayList<Shoe> shoes = createTheShoes();
Shoe [][] randomShoes;
randomShoes = new Shoe[6][9];
for(int row=0; row < NUMBER_OF_ROWS; row++) {
for(int col=0; col < NUMBER_OF_COLS; col++) {
for(int i=0;i<shoes.size();i++) {
randomShoes[row][col] = shoes.get(i);
}
}
}
return null;
}
I don't think is correct as I only want 52 random shoes but I can't think of which way the loops should go. Also how would I RANDOMLY remove them, Math.random() is the only random method we have learnt. Also in the last 4 rows there would be four blank spaces that can be filled up with null but am not sure how to do this...
Any help appreciated thanks! :D: