Fill in 2d array

Hi,

The 2d int array below:

int testArray[][] = new int[4][5];   

I want filling with the following:

	1111
	1001
	1001
	1001
	1111

What’s the best way to go about this?

Obviously this is how to simply fill in with 1’s:


for(int y=0; y<5; y++)
{
	for(int x=0; x<4;x++) {
		testArray[x][y] = 1;
	}
}

I came up with this, but doesn’t look the best:


private void makeRoom(int[][]testArray, int w, int h, int tileOuterId, int tileInnerId) {
		for(int y=0; y<h; y++)
		{
			for(int x=0; x<w;x++) {
				if(x==0 || x==w-1 || y==0 || y==h-1)
					testArray[x][y] = tileOuterId;
				else
					testArray[x][y] = tileInnerId;
			}
		}
	}

Just would like a method which takes in the dimensions of the array and the outer side of it is filled with 1’s if you know what I mean?

Thanks,
Steve