I want to change different instance variables in every loop of a for-loop.
I can't do it with an array or ArrayList
because the variables are @FXML
definitions.
See the example below:
@FXML
public label foo1;
@FXML
public label foo2;
public void changeLabels() {
for (int i = 0; i < 2; i++) {
//Here I want to access the variables foo1/foo2 depending on the value of i
// Thought about something like
// String temp = "foo" + (i + 1);
// but I dont know how to go on
}
}
Why can't I ask this question? It was marked as duplicate but I explained why the linked question wont work for me.