title: Multi-dimensional array, how can I check all adjacent tiles that are IN bounds to certain cells?
body: <p>I've created a 12x12 grid, and within this grid I have created 'infected' tiles, when one infected tile is surrounded by other infected tiles, the surrounded cell becomes a diseased tile. I was wondering if there was a nice way of checking adjacent, in bounds cells for their value?</p>
  
  <pre class="lang-java prettyprint-override"><code>public static void diseaseTiles() {
      int i, j;
      for(i = 0; i &lt; 12; i++) {
          for(j = 0; j &lt; 12; j++) {
              if(myGrid[i][j] == 'I'){
                  int left, right, up, down;
                  if(i == 0) {
                      left = 1;
                  }
                  if(i == 11) {
                      right = 1;
                  }
                  if(j == 0) {
                      up = 1;
                  }
                  if(j == 11) {
                      down = 1;
                  }
                  //this is where I've gotten stuck
                  //I was going to use the above int's to determine
                  //whether or not the adjacent tile in that direction
                  //should be checked (they're the border of the grid)
              }
          }
      }
  }
  </code></pre>