How do I create a 2D Array of images that are randomly distributed on the array?

261 views Asked by At

I want to create a 2D array of images in my applet. I need a 4x4 grid with 4 images and 4 of each image spread out across the array randomly. there are a few answers on here but I don't understand how to use them.

1

There are 1 answers

0
VD007 On

You can declare

Image[][] myImages = new Image[4][4]

and then assign it a value as following.

myImages[0][1] = "image1"
......

or you can use a loop,

for (int i = 0; i < 4; i++)
{
    for (int j = 0; j < 4; j++)
    {
        myImages[i][j] = "whatever to get your image"
    }
}