noc-examples-processing icon indicating copy to clipboard operation
noc-examples-processing copied to clipboard

Probability

Open LucasColas opened this issue 6 years ago • 5 comments
trafficstars

Hello, I'm trying to learn processing and I'm working on this exercise :

int [] stuff = new int[5]

stuff[0] = 1; stuff[1] = 1; stuff[2] = 2; stuff[3] = 3; stuff[4] = 3;

int index = int(random(stuff.length));

But I have an error : "Syntax error, maybe a missing ] character?"

Could you help me ?

LucasColas avatar Oct 13 '19 15:10 LucasColas

You miss the ";" at line 1 or maybe instead of int [] you should write int[]

MagusX avatar Oct 13 '19 15:10 MagusX

You missed a " ; " perhaps is that

MonkeyDLy avatar Oct 13 '19 15:10 MonkeyDLy

Thanks for the answer ! Now my code is : int[] stuff = new int[5];

stuff[0] = 1; stuff[1] = 1; stuff[2] = 2; stuff[3] = 3; stuff[4] = 3;

int index = int(random(stuff.length));

And I have another error : "Missing right curly bracket "}" " and "unexpected token"...

LucasColas avatar Oct 13 '19 15:10 LucasColas

"unexpected token: [" exactly.

LucasColas avatar Oct 13 '19 15:10 LucasColas

Ok, I had to add {} : int[] stuff = new int[5]; { stuff [0] = 1; stuff [1] = 1; stuff [2] = 2; stuff [3] = 3; stuff [4] = 3;

int index = int(random(stuff.length));

}

but why ?

LucasColas avatar Oct 13 '19 16:10 LucasColas