/* 6.914, Example 2.1 Use these to collect similar arguments that you want to access in an organized fashion. You can create arrays of integers, floats, chars, colors, Strings, etc. The general form for declaring arrays is: int[] intArrayName = new int[arraySize]; color[] colorArrayName = new color[arraySize]; Alternatively, if you know the whole set of contents for an array, you can use this form: int[] intArrayName2 = {4, 5, 10, 3, 7}; // all elements separated by commas (You can only use this form for primitive types: booleans, ints, floats, and chars.) Arrays are zero-indexed, so if they are of size n (meaning arraySize is n), you can put elements into positions 0 through n-1. The general form for putting information into arrays is: arrayName[arrayPosition] = elementToInsert; The general form for retrieving information from an array is like this: arrayName[positionToRetrieve] So, to print an array element to the screen, you’d use this format: println(“The information is “+arrayName[positionToRetrieve]); You can access the length of your array as an int by using "arrayName.length". */ String[] myStrings = new String[6]; color[] myColors = new color[10]; int[] myInts = { 30, 80, 115, 139, 172}; void setup(){ size(400, 400); noLoop(); noStroke(); smooth(); } void draw(){ // this will print out asteriks to the window underneath for (int i = 0; i < myStrings.length; i++){ myStrings[i] = ""; // intializing it to empty instead of "null" for (int j = 0; j < i; j++){ myStrings[i] += "* "; // try it! } println(myStrings[i]); } // this will assign colors in an array to variables depending on their position for (int i = 0; i < myColors.length; i++){ myColors[i] = color(i*20, i*10, i*13); } // this will print colors as previously determined by the array float widthOfRects = width/myColors.length; for (int i = 0; i < myColors.length; i++){ fill(myColors[i]); rect(i*widthOfRects, 0, widthOfRects, height); } // this will draw ovals on the window for (int i = 0; i < myInts.length; i++){ // reusing this array fill(myColors[i]); ellipse(width/2, myInts[i], 15, 10); } }