Reading:
These array examples are written for Java but should work in Processing as well provided that you replace
public static void main()
with
void setup()
.
Focus your attention on the basic arrays material in Sections 8.2.1-8.2.2, declaring, initializing and using arrays. After you’ve read through these sub-sections, try the following exercises:
Do all the things specified in these comments.int[] test = new int[5]; // 1. Draw a picture of the memory structure created by this statement. System.out.println(test); // 2. Can you explain the output you get here? // 3. Add a statement here to print out the first element of the array. What is its value and how did it get this value? System.out.println(test[5]); // 4. Explain what this does and why?
for
loop to
fill its elements with the integers 1 through 100.