51

Arrays

An array is a way of storing lots of variables in one place. In this example the array is called 'y' but it could be called anything. y contains 3000 memory locations each capable of storing a float variable. The contents of each element in an array is accessed using the index position of the element in the array. Array indexes start at 0. The y array starts at 0 and goes up to 2999 giving 3000 total storage locations. To better understand this add this line of code:

println(i + " " + x[i]);

right after y[i] = random(-1000, 200);

In this example 3000 y locations are stored in a single array variable called y. The draw method then uses these to position the snowflakes.