I'm getting the error java.lang.reflect.InvocationTargetException
whenever I use a loop, if I just create a rectangle and assign it to an array, it works but if I try to assign it in a loop this pops up. I tried to search it up but most answers revolved around an FXML file but I don't have one. Is it required? Would the error go away if I added one?
public class ChessBoard extends Application {
public static void main(String[] args) {
Application.launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
ChessBoard(primaryStage);
}
public void ChessBoard(Stage primaryStage) {
primaryStage.setTitle("");
Group root = new Group();
Scene scene = new Scene(root, 520, 520, Color.WHITE);
Rectangle [][]tiles = new Rectangle[4][4];
for(int i = 0; i < tiles.length; i++) {
for(int j = 0; j < tiles[i].length; i++) {
tiles[i][j] = new Rectangle();
}
primaryStage.setScene(scene);
primaryStage.show();
}
}