| An array is a list of data. It is possible to have an array of any  type of data. Each piece of data in an array is identified by an index  number representing its position in the array. The first element in the  array is [0], the second element is [1], and so on. Arrays are similar to objects, so they must be created with the keyword new. Every array has a variable length which is an integer value for the total number of elements in the array. (People are often confused by the use of length() to get the size of a String and length to get the size of an array. Notice the absence of the parentheses when working with arrays.) After trying to apply this to my metaphor 'Arrays are vending machines", I found that a vending machine is actually fits a 2d array, so I did some more research into 2d arrays and this example of how they work on Processing help website was really helpful and key into my understanding An array keeps track of multiple pieces of information in linear order, a one-dimensional list. However, the data associated with certain systems (a digital image, a board game, etc.) lives in two dimensions. To visualize this data, we need a multi-dimensional data structure, that is, a multi-dimensional array. A two-dimensional array is really nothing more than an array of arrays (a three-dimensional array is an array of arrays of arrays). Think of your dinner. You could have a one-dimensional list of everything you eat: (lettuce, tomatoes, salad dressing, steak, mashed potatoes, string beans, cake, ice cream, coffee) Or you could have a two-dimensional list of three courses, each containing three things you eat: (lettuce, tomatoes, salad dressing) and (steak, mashed potatoes, string beans) and (cake, ice cream, coffee) In the case of an array, our old-fashioned one-dimensional array looks like this: int[] myArray = {0,1,2,3};And a two-dimensional array looks like this: int[][] myArray = { {0,1,2,3}, {3,2,1,0}, {3,5,6,1}, {3,8,3,4} };   | 
Monday, 30 May 2011
Research into arrays..
I had to do some extra research into arrays, as I had done all my research on variables, I found that the processing help site really helped, this is there explanation:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment