I’m trying to insert a blank space to all the elements of a 2D character array. Does this work?
public class AsciiDisplay {
private char [][] grid;
public AsciiDisplay() {
grid = new char [30][15];
}
public void updateGrid() {
//Here is the code to initialize all the elements on my 2D char array with a blank space.
for(int i = 0; i < grid.length; i++) {
for(int j = 0; i <grid[0].length; i++) {
grid[i][j] = ' ';
}
}
}
}
Just a correction your loop should be like below because inside second loop you need to loop on array which you get in the first loop.