title: Wrap Around Grid - errors on east/west only
body: <p>I have four methods that check whether or not a given grid location is next to an occupied location (value of 1). The grid is assumed to wrap around, ie, if in a 50x50 grid[0][1] is the given location and grid[49][1] is occupied, the method should return true/ My checkNorth and checkEast method are working fine, but I get an ArrayIndexOutofBoundsException: -1 error for either the south or west methods every time I run the program. I checked my math and I think it should work - am I using the modulo incorrectly, or am I missing something else?
  EDIT: Clarified the wrapping criterion, word use correction.</p>
  
  <pre><code>boolean checkWest(int indexA, int indexB)
  {
      if (indexA-1 &gt; 0)
      {
          if (grid[indexA-1][indexB] == 1)
              {
              return true;
              }
      }
      if (indexA-1 &lt; 0)
          {
          if (grid[(indexA-1)%width][indexB] == 1)
              {return true;}
          else return false;
          }
  return false;   
  }
  </code></pre>