private void drawGrid(){
for(int i = 0; i<3; i++){
GLine line = new GLine(0,0,21*i,211*i);
add(line);
}
}
Is there a way to change the name of the gline I create each time the for loop is run?
private void drawGrid(){
for(int i = 0; i<3; i++){
GLine line = new GLine(0,0,21*i,211*i);
add(line);
}
}
Is there a way to change the name of the gline I create each time the for loop is run?
You can use an array of GLine
, and store a new GLine
in each index:
private void drawGrid(){
GLine[] glines = new GLine[3];
for(int i = 0; i<3; i++){
GLine line = new GLine(0,0,21*i,211*i);
glines [i] = line;
}
}
This way, glines[0]
referes to the first GLine
, glines[1]
refers to the second one etc.