Problem with for loops

When I run the following code, when I try to println the variable a in the FOR loop, it doesn’t show up on the window. I would expect the loop to be entered and iterated because m[0] is greater than 0, and so is m[1], m[2], etc. Any ideas?

int stars=750;
int a=0;
float[] m = new float[stars];
float b=0;
float[] x = new float[stars];
int m1=1;

void setup() {
size(800, 700);
for (int i=1; i<stars; i++) {
x[i]=random(0, 800);
m[i]=m1;
}
m[10]=5;
m[13]=0;
m[14]=0;
m[15]=0;
}

void go() {
for (int k=0; k < m[10]; k++) {
for (int n=0; m[n] > 0; n++) {
a=n+1;
println(a);
}
x[a]=random(0, 800);
println(x[a]);
}
}

void draw() {
go();
}

You start with 1 here,
so m[0] is 0 and not 1

1 Like