Checking for surrounding mines
Procedural way

I usually suggest doing it in a way such that you don't have to perform to many checks. Also, I think that iterating on cells and updating the contour when you find a mine is logically simpler than detecting adjacent mines for each cell.

I will not write code for you (you are trying to learn something in the end), but I will outline the overall algorithm, and offer an object-oriented approach to the problem - which has smaller checks than your current solution and is substantially more readable.

Phase 1: corners

Write, for each corner, a single if statement. If it is a mine, update the three surrounding cells if they are not mines.

Phase 2: borders (- corners)

Iterate over the four borders (with 4 for loops), updating the 5 adjacent cells if they are not mines.

Phase 3 (final): the center of the board

For each cell in the center, if it is a mine, update all 8 surrounding cells if they are not mines.

Object-oriented way

Let every cell be an instance of a class Cell¹. A Cell knows (and exposes) whether it is a mine or not. It also has a public method incrementNeighborCounter()².

Done.

Really, we're done. (Yes, you need to implement Cell, but the essential part of programming [designing] has been done already, and you seem capable of writing the code of Cell).

How does it work? You go through the board once, using the pattern described in the "Procedural way" above. But you don't check if a cell is a mine or not before telling it to increment its counter (because that has been delegated to how a Cell presents itself [mines can even count their neighboring mines too now]), you just call incrementNeighborCounter() and move ahead. Part of the logic is now in Cell and your code is simpler, lighter on the brain and less likely to contain bugs.

¹ - It could be an Interface or an Abstract Class, just don't go overboard and add unnecessary complexity.

² - Name it whatever you feel like, this is not an exact science. Just try to be descriptive and use the name as documentation.



Just in case you are wondering, a very simple Cell implementation could use a boolean for being a mine or not and an integer for counting how many mine neighbors it has.