Monday, April 13, 2015

["Hip","Hip"] Array

ARRAY

An array is a container object that holds a fixed number of values of a single type. The length of an array is established when the array is created. After creation, its length is fixed. Many people have seen examples of an array already but dont really notice it. We have seen in already in the main method  of the "Hello World!" application. 
Illustration of an array as 10 boxes numbered 0 through 9; an index of 0 indicates the first element in the array
Each item in an array is called an element, and each element is accessed by its numerical index. As shown in the preceding illustration, numbering begins with 0. The 9th element, for example would therefore be accessed at index 8. 

What I learned?
  What I learned while doing this unit basically was how to use an array and what an array is. Coming into this unit I had no clue how to use it but now I have some sort of idea how to use it in a piece of code. What an array is useful is, is that by using arrays to can easily make lists of variables using only one command. Arrays I learned are also useful because instead of making a long list of If, Else statements you can just use arrays and save lots of time in writing your codeSo how exactly do you reference variables in an array?
In Java all values, or data stored in an array is assigned a number value starting with 0. If i were to print x[0] from above the output would be "a". If i were to print x[1] the output would be "b".