Home > Net >  How do I create a grid filled row by row from the pattern provided by the one-dimensional pattern pa
How do I create a grid filled row by row from the pattern provided by the one-dimensional pattern pa

Time:02-10

Whenever I try to compile this code that sets the grid for a QR code I get an error: Cannot load from object array because "QRCode.grid" is null at QRCode.setGrid(QRCode.java:76). I think there is an error in the last line.

public void setGrid(int dim, int [] pattern) {
        if(pattern==null)
             
         grid=new int[dim][dim];
         
         for(int row=0;row<dim;row  ) {
             for(int col = 0; col < dim; col  ) {
                 
                 grid[i][j]=pattern[row*dim col];
            
                } 
            }
    
    }

CodePudding user response:

  •  Tags:  
  • Related