When you initiate the array (i.e. int[][] array = new int[20][20]; ) every position is already filled with 0 (since a primitive cannot be null). So, if zero is not one of the numbers you are using, simply cycle through the arrays with a nested loop replacing 0 with 99.
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
Yes, as masijade mentioned, initialize the array elements to the value you want to represent "empty" before you start filling it. You didn't say what the valid range for your number entries was, but filling with -1 or Integer.MIN_VALUE can be useful values to represent "unset".
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
Are you using Java 1.5 or later? If so, make it an Integer array, rather than an int array. Then "empty" spots will be null and you just (after having filled it with the random numbers) cycle through with an == null check. And, you can still do array[i][j] = 1; or some other int, because autoboxing will automatically convert it to an Integer. You can also, later, use the Integer as if it were a normal int. That seems to be easiest solution.
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494