Minesweeper BombCounts I have a method which checks all of its surrounding squares and returns the number of bombs around it. But it's really long code and ugly, so can it be shorten?
final int MINE =10

for (int x = 0; x &lt; counts.length; x++) {
    for (int y = 0; y &lt; counts[0].length; y++) {
    if (counts[x][y] != MINE) {
    int Minesearch = 0;
    if (x &gt; 0 &amp;&amp; y &gt; 0 &amp;&amp; counts[x-1][y-1] == MINE) {//up left
        Minesearch++;
    }
    if (y &gt; 0 &amp;&amp; counts[x][y-1] == MINE) {//up
        Minesearch++;
    }
    if (x &lt; counts.length - 1 &amp;&amp; y &gt; 0 &amp;&amp; counts[x+1][y-1] == MINE) {//up right
        Minesearch++;
    }
    if (x &gt; 0 &amp;&amp; counts[x-1][y] == MINE) {//left
        Minesearch++;
    }
    if (x &lt; counts.length - 1 &amp;&amp; counts[x+1][y] == MINE) {//right
        Minesearch++;
    }
    if (x &gt; 0 &amp;&amp; y &lt; counts[0].length - 1 &amp;&amp; counts[x-1][y+1] == MINE) {//down left
        Minesearch++;
    }
    if (y &lt; counts[0].length - 1 &amp;&amp; counts[x][y+1] == MINE) {//down
        Minesearch++;
    }
    if (x &lt; counts.length - 1 &amp;&amp; y &lt; counts[0].length - 1 &amp;&amp; counts[x+1][y+1] == MINE) {//down right
        Minesearch++;
    }
    counts[x][y] = Minesearch;
    }
    }
}
}
It can be shortened and &quot;beautified&quot; by refactoring the bounds cyhecking and mine checking into internal method:
private boolean isWithinBounds(int x, int y) {
    return x &gt;= 0 &amp;&amp; y &gt;= 0 &amp;&amp; x &lt; width &amp;&amp; y &lt; height;
}

private boolean isMine(int x, int y) {
    return field[x][y] == MINE;
}

Then the mine count becomes trivial (we can assume that the center of the 3x3 square does not have a mine, otherwise the player would have exploded and ended the game):
for (int x1 = x - 1; x1 &lt;= x + 1; x1++) {
    for (int y1 = y - 1; y1 &lt;= y + 1; y1++) {
        if (isWithinBounds(x1, y1) &amp;&amp; isMine(x1, y1) {
            mineCount++;
        }
    }
}

What we have done is breaking code into methods, each of which implement a small and well defined function. Because each method does exactly one thing, they become easier to understand, maintain and test.
You should check Java naming conventions. Variable names should be in camelCase, startingWithSmallLetter.
Variable and method names should describe the reason why the code exists. E.g. mineSearch is confusing as the variable does not search mines, it just keeps count of them. Thus mineCount is a better alternative.
Counts is also confusing as it contains a value named MINE which obviously is a marker for a cell containing mine but it also contains the surrounding mine counts. I did a minesweeper clone (or actually a minesweeper solver) once and I used an array containing Cell-objects. The Cell object provided methods for querying the status of the cell (stepped on, flagged, unknown) and the number of surrounding mines if it had been stepped on.