private void bfs(char[][] grid,int i,int j){
  Queue<Point> queue=new ArrayDeque<>();
  grid[i][j]='0';
  queue.add(new Point(i,j));
  while (!queue.isEmpty()) {
    Point p=queue.poll();
    for (    int[] dir : dirs) {
      int row=p.row + dir[0];
      int col=p.col + dir[1];
      if (row >= 0 && row < grid.length && col >= 0 && col < grid[row].length && grid[row][col] == '1') {
        grid[row][col]='0';
        queue.add(new Point(row,col));
      }
    }
  }
}

private void bfs ( char [ ] [ ] grid , int i , int j ) { Queue < Point > queue = new ArrayDeque < > ( ) ; grid [ i ] [ j ] = '0' ; queue . add ( new Point ( i , j ) ) ; while ( ! queue . isEmpty ( ) ) { Point p = queue . poll ( ) ; for ( int [ ] dir : dirs ) { int row = p . row + dir [ 0 ] ; int col = p . col + dir [ 1 ] ; if ( row >= 0 && row < grid . length && col >= 0 && col < grid [ row ] . length && grid [ row ] [ col ] == '1' ) { grid [ row ] [ col ] = '0' ; queue . add ( new Point ( row , col ) ) ; } } } }
iterative . find the region and mark as ' 0 ' .
