View Single Post
Old Apr 30th, 2005, 8:31 PM   #1
trumpetelf
Newbie
 
Join Date: Apr 2005
Posts: 4
Rep Power: 0 trumpetelf is on a distinguished road
checking to see if a 2D array is inbounds

I'm currently designing a program that requires the use of a 2D array. One of the important things that this program must do before executing any specific code is to verify that the arguement passed into the program is within the bounds of the array.

I want to think that the following concept is correct and I'm stuck on putting it into Java. Someone correct me if the concept is wrong!

3 arguements are passed into method: int[][] lawn; int x; int y;

//test x
for (int i = 0; i < x.length; i++)
if x > lawn[x][i]
return false;
//test y
for (int i=0; i < y.length; i++)
if y > lawn[i][y]
return false
trumpetelf is offline   Reply With Quote