For JavaScript, the code would look like this:
if (array[x] != undefined && array[x][y] != undefined) {
array[x][y] = "foo";
}
Is there an equivalent simple method for achieving this in Java?
I have tried checking if the field is null or not, but that doesn't seem to work. Additionally, the concept of 'undefined' does not appear to function in Java.