# Problem with for loops

**URL:** <https://discourse.processing.org/t/problem-with-for-loops/29425>\
**Category:** Beginners\
**Created:** [April 16, 2021, 7:59pm UTC](https://discourse.processing.org/t/problem-with-for-loops/29425 "2021-04-16T19:59:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kairama15](https://avatars.discourse-cdn.com/v4/letter/k/35a633/32.png) [@kairama15](https://discourse.processing.org/u/kairama15)\
**Post date:** [April 16, 2021, 7:59pm UTC](https://discourse.processing.org/t/problem-with-for-loops/29425/1 "2021-04-16T19:59:34Z")

</div>

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();  
}

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [April 16, 2021, 8:22pm UTC](https://discourse.processing.org/t/problem-with-for-loops/29425/2 "2021-04-16T20:22:34Z")

</div>

> [@kairama15](#):
>
> for (int i=1; i\<stars; i++) {

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