Minesweeper, Bombcount method
A double-for-loop over x and y seems appropriate.

Also, it seems like a good idea to assign (SmartSquare)board.getSquareAt(...) to a variable.

int bombNum = 0;
for    (int xOffset = -1; xOffset &lt;= 1; xOffset++)
   for (int yOffset = -1; yOffset &lt;= 1; yOffset++)
   {
      if (xOffset == 0 &amp;&amp; yOffset == 0)
      {
         continue;
      }
      SmartSquare neighbour = (SmartSquare)board.getSquareAt(xLocation+xOffset, yLocation+yOffset);
      if (neighbour != null &amp;&amp; neighbour.getBomb())
      {
         bombNum++;
      }
   }
return bombNum;