# Unexpected token - void

**URL:** <https://discourse.processing.org/t/unexpected-token-void/8099>\
**Category:** Coding Questions\
**Created:** [February 4, 2019, 6:38am UTC](https://discourse.processing.org/t/unexpected-token-void/8099 "2019-02-04T06:38:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ClashAdam](https://avatars.discourse-cdn.com/v4/letter/c/49beb7/32.png) [@ClashAdam](https://discourse.processing.org/u/ClashAdam)\
**Post date:** [February 4, 2019, 6:38am UTC](https://discourse.processing.org/t/unexpected-token-void/8099/1 "2019-02-04T06:38:53Z")

</div>

This errors shows for no reason, in first tab

```auto
Drop[] drops = new Drop[500]

void setup() {
  size(640, 360) ;
  for (int i = 0; i < drops.length; i++) {
    drops[i] i = new Drop() ;
  }
}

void draw() {
  background(230, 230, 250)
  for (int i = 0; i < drops.length; i++) {
   drops[i].fall() ;
   drops[i].show() ;
  }
}

```

second tab

```auto
class Drop {
  float x = random(width) ;
  float y = random(-500, -50) ;
  float z = random(0, 20) ;
  float len = map(z, 0, 20, 10, 20) ;
  float yspeed = map(z, 0, 20, 1, 20) ;
  float len - random(10, 20) ;
  
  void fall() {
    y = y + yspeed
    float grav = map(z, 0, 20, 0, 0.2) ;
    yspeed = yspeed + grav;
  
    if (y > height) {
      y = random(-200, -100) ;
      yspeed = map(z, 0, 20, 4, 10) ;
    }
  }
  
  void show() {
    stroke(138, 43, 226) ; 
    line(x,y,x,y+len) ;
  }
}

```

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [February 4, 2019, 6:53am UTC](https://discourse.processing.org/t/unexpected-token-void/8099/2 "2019-02-04T06:53:07Z")

</div>

pls

- format your code in Processing IDE [crtl][t]
- paste here at your above post by using

> \</\>

code formatter

usually you write code line by line  
so only one can be wrong  
so a code like that could never happen???

```auto
// https://discourse.processing.org/t/unexpected-token-void/8099

Drop[] drops = new Drop[500]; // ; needed

void setup() {
  size(640, 360);
  for (int i = 0; i < drops.length; i++) {
    // drops[i] i = new Drop() ;
    drops[i] = new Drop();
  }
}

void draw() {
  background(230, 230, 250); // ; needed
  for (int i = 0; i < drops.length; i++) {
    drops[i].fall();
    drops[i].show();
  }
}

//second tab
class Drop {
  float x = random(width);
  float y = random(-500, -50);
  float z = random(0, 20);
  float len = map(z, 0, 20, 10, 20);
  float yspeed = map(z, 0, 20, 1, 20);
// float len - random(10, 20) ; // can only have one declaration of a variable!

  void fall() {
    y = y + yspeed; // ; needed
      float grav = map(z, 0, 20, 0, 0.2);
    yspeed = yspeed + grav;

    if (y > height) {
      y = random(-200, -100);
      yspeed = map(z, 0, 20, 4, 10);
    }
  }

  void show() {
    stroke(138, 43, 226);
    len -= random(10, 20); // add here ??
    line(x, y, x, y+len);
  }
}

```

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [February 4, 2019, 6:53am UTC](https://discourse.processing.org/t/unexpected-token-void/8099/3 "2019-02-04T06:53:50Z")

</div>

Each line needs to finish with a semi-colon aka `;`

This does not apply to if-else, while() or for() loops.

Kf

---

<div class="post-metadata">

**Author:** ![ClashAdam](https://avatars.discourse-cdn.com/v4/letter/c/49beb7/32.png) [@ClashAdam](https://discourse.processing.org/u/ClashAdam)\
**Post date:** [February 5, 2019, 10:12am UTC](https://discourse.processing.org/t/unexpected-token-void/8099/4 "2019-02-05T10:12:49Z")

</div>

Thank You! I just wanted to make a “rain” and i didn’t tought that i willl get a mistake like this
