// using arrays, draw a series of random lines on the screen size (400,400); background (127); smooth(); // create array of vallues that will describe a line // x1, y1, x2, y2 // note the use of the brackets - they indicate to Processing that you want to create an array of the specified data type. // also note the use of the word 'new' and then the number 4 inside the second set of brackets - // this tells Processing that you want to create 4 locations in that array. // if you wanted to, you could fill the array with values right away by using this snippet of code instead of the one below: // float[] line1 = {0, 0, 200, 200}; float[] line1 = new float[4]; // this for loop sets how many lines will be drawn on the screen by specifying the number of times the code below is run // note that ++ is shorthand for i=i+1 for (int numcyc=0; numcyc<6; numcyc++) { // fill the array by addressing the specific location within the array and giving it a value. iterate to fill all. // note that the array starts at position 0 and goes to 3 // even though you initialized the array with the number 4 // summary: 4 positions, numbered 0 through 3 for (int j=0; j<4; j++) { line1[j] = random(0,400); } // now that the array is full of new values, we can read those values out of their locations and use them to draw lines // when accessing the numbers, use brackets with the position of the value you want to access inside // in this case, I want to know the values stored in positions 0 -3 in order to get the x1, y1, x2, y2 values I need to draw a line. line (line1[0], line1[1], line1[2], line1[3]); }