# \[SOLVED\] Can't put int i in if statement in for loop- Help!

**URL:** <https://discourse.processing.org/t/solved-cant-put-int-i-in-if-statement-in-for-loop-help/3848>\
**Category:** Coding Questions\
**Created:** [September 26, 2018, 5:06am UTC](https://discourse.processing.org/t/solved-cant-put-int-i-in-if-statement-in-for-loop-help/3848 "2018-09-26T05:06:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dinator14](https://avatars.discourse-cdn.com/v4/letter/d/e19adc/32.png) [@Dinator14](https://discourse.processing.org/u/Dinator14)\
**Post date:** [September 26, 2018, 5:06am UTC](https://discourse.processing.org/t/solved-cant-put-int-i-in-if-statement-in-for-loop-help/3848/1 "2018-09-26T05:06:31Z")

</div>

I get the error variable i doesn’t exist and I’m not sure why. Without the if statement I don’t get errors. I’m pretty sure I’ve also seen the use of if statements and whatever int was in the for loop used in the if so I’m really confused.

```auto
  int[] headx= new int[2500];
  int[] heady= new int[2500];
  int total= 2;
  
  void move()
  {
    for(int i=total; i>total; i--);
    {
      if(i!=1)
      {
        headx[i]=headx[i-1];
        heady[i]=heady[i-1];
      }

```

---

<div class="post-metadata">

**Author:** ![tony](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tony/32/949_2.png) [@tony](https://discourse.processing.org/u/tony)\
**Post date:** [September 26, 2018, 5:29am UTC](https://discourse.processing.org/t/solved-cant-put-int-i-in-if-statement-in-for-loop-help/3848/2 "2018-09-26T05:29:12Z")

</div>

> [@Dinator14](#):
>
> for(int i=total; i\>total; i–);

That semicolon sneaked in, and so the IDE think’s it’s a body-less for-loop.

---

<div class="post-metadata">

**Author:** ![Dinator14](https://avatars.discourse-cdn.com/v4/letter/d/e19adc/32.png) [@Dinator14](https://discourse.processing.org/u/Dinator14)\
**Post date:** [September 26, 2018, 12:24pm UTC](https://discourse.processing.org/t/solved-cant-put-int-i-in-if-statement-in-for-loop-help/3848/3 "2018-09-26T12:24:33Z")

</div>

lol i’m blind thanks
