Can't understand what I am doing wrong :( I want to fill my array with spaces. But receive a mistake Exception in thread "main" java.lang.Error: Unresolved compilation problem: j cannot be resolved to a variable
at Field.space(Field.java:11)
at Main.main(Main.java:6)
This is my simple code:
public class Main {
public static void main (String[] args){
Field field = new Field();
field.space();
}
}
public class Field {
private static final int ArraySize = 3;
private char spacesymbol = ' ';
private char[][] array = new char [ArraySize][ArraySize];
public void space() {
for (int i=0; i<ArraySize; i++){
for (int j=0; j<ArraySize; j++)
array[i][j]= spacesymbol;
System.out.println("[" + array[i][j] + "]");
}
}
}