Can someone help with my java syntax??

Hey, i'm really new to code, but I need help on my project, I keep getting "unexpected token:void" i was hoping someone could clear this up for me! Please! here is my code

float rota[]; // ring animation 
float pos1[];
float pos2[];
float vel[];
float aax[];
float aay[];
int n = 50;

import ddf.minim.spi.*;
import ddf.minim.signals.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.ugens.*;
import ddf.minim.effects.*;
import ddf.minim.*;
AudioPlayer player;
Minim minim;

import gifAnimation.*;

PImage[] animation;
Gif loopingGif;
Gif nonLoopingGif;
boolean pause = false;

void setup() {
  size(800, 333);

  vel = new float[n];
  pos1= new float[n];
  pos2= new float[n];
  rota= new float[n];
  aax = new float[n];
  aay = new float[n];

  for (int i=0; i<n; i++) {
    vel[i] = random(0.02);
    pos1[i]= random(width/2);
    pos2[i]= random(height/2);

    println("gifAnimation " + Gif.version());
    // create the GifAnimation object for playback
    loopingGif = new Gif(this, "giphy.gif");
    nonLoopingGif = new Gif(this, "giphy.gif");;
    // create the PImage array for the interactive display
    animation = Gif.getPImages(this, "giphy.gif");

    minim = new Minim(this);
    player = minim.loadFile("gandalf_onering.wav"); // audio

  void draw() {
    background(255 / (float)height * mouseY);
    image(loopingGif, 10, height / 2 - loopingGif.height / 2);
    image(nonLoopingGif, width/2 - nonLoopingGif.width/2, height / 2 - nonLoopingGif.height / 2);
    image(animation[(int) (animation.length / (float) (width) * mouseX)], width - 10 - animation[0].width, height / 2 - animation[0].height / 2);

    translate(width/2, height/2);
    for (int i=0; i<n; i++) {



      point(aax[i], aay[i]);

      rota[i]+= 0.001;


  • Answer ✓

    hit ctrl-t in the editor and it'll indent everything nicely for you and warn you of missing brackets

    in this case, draw() should be on the same level as setup(). you're missing a } after line 63. and another after line 85.

    also, please read the sticky post about posting code.

  • Sorry, I didn't see the sticky post :$

    Thank you very much for your help, but what do you mean when you say draw() should be on the same line as setup()

  • OHH NVM I FIGURED IT OUT!! Thank you so much!!! :)>-

Sign In or Register to comment.