Sunday, June 3, 2007

Arrays

Using arrays is a way to extend the storage of variables to include a list of values, instead of just a single value. It is a way for programmers to handle large quantity of data efficiently.

Arrays are specified using a square bracket (int marks[]) and individual elements in an array can be referred to by their index:
   marks[21] = 68;
marks[14] = 79;
Because the index is just an integer value, we can always use a variable to represent the index so that we can parse through the array elements one by one.
   for(int i=0; i<marks.length; i++)
{
marks[i] = 0;
}

No comments: