I'm learning Java and I'm fairly new to this. Here is my problem with some pseudocode:
public void objectCaller(int objectNumber) {
switch(objectnumber) {
case 1:
object1.setFill(color.RED);
break:
case 2:
object2.setFill(color.RED);
break;
.
.and so on
}
}
Is there a way to replace it in a way with something like that?
public void objectCaller(int objectNumber) {
(object + objectnumber).setFill(color.RED);
}
It is not a concrete problem. I was just thinking about if it is possible to assemble the object names.
Aucun commentaire:
Enregistrer un commentaire