------
## 最终结论
```python
def dfs(grid, i, j):
    if i < 0 or i >= len(grid) or j < 0 or j >= len(grid[0]) or grid[i][j] == '0':
        return
    grid[i][j] = '0'  # Mark the land as visited
    # Explore all four directions
    dfs(grid, i + 1, j)  # Down
    dfs(grid, i - 1, j)  # Up
    dfs(grid, i, j + 1)  # Right
    dfs(grid, i, j - 1)  # Left

def numIslands(grid):
    if not grid:
        return 0
    
    count = 0
    for i in range(len(grid)):
        for j in range(len(grid[0])):
            if grid[i][j] == '1':  # Found an unvisited land
                count += 1
                dfs(grid, i, j)  # Mark all connected lands as visited
                
    return count
```