Wednesday, September 16, 2015

Arrays in java

An array is a group of variables (called elements or components) containing values that all

have the same type. Arrays are objects, so they’re considered reference types. As you’ll soon



see, what we typically think of as an array is actually a reference to an array object in memory.

The elements of an array can be either primitive types or reference types (including



arrays). To refer to a particular element in an array, we specify

the name of the reference to the array and the position number of the element in the array.

The position number of the element is called the element’s index or subscript.

This array contains
 
12 elements. A program refers to any one of these elements with an array-access

expression that includes the name of the array followed by the index of the particular element

in square brackets ([]). The first element in every array has index zero and is sometimes

called the zeroth element. Thus, the elements of array c are c[0], c[1], c[2] and so

on. The highest index in array c is 11, which is 1 less than 12—the number of elements



in the array. Array names follow the same conventions as other variable names.

 

1 comment:

  1. Interesting class and like the diagrams , the visualization is always a plus as it helps understand what you are saying . Thank you Mr,Gabr

    ReplyDelete