What is an Array

An Array can be defined as a finite ordered set of homogeneous elements. Here, finite means that there is a specific number of elements in an array. By the term ordered we means that elements of array are arranged in a sequence so that first, second, third etc. The homogeneous property of array means that all elements in the array must be of the same type. It is use to handle a large amount of data without the need to declare many indivisual variable. The array elements are store in a contigious memory location.

 

SMITH                   ALLEN                   SANIT                    SANJAY

 

The concept of array help us to store group of value under a single name and refer directly to a particular value. This makes the program very simple and efficient. Array are a collection of related data items with similar data types and having a common name.

For Example….if we have to store the name of four friends, SMITH, ALLEN, SANIT, SANJAY. We will declare an array named friends and store the above names in it.

DECLARING AN ARRAY…..

The first step to creating an array is creating a variable that hold the array objects same as other variable. Array variable indicates the type of object, and the name of the array, followed by empty braces([]).

String friends[4];

In this indicating that the detail is about friends , and [4] indicates that this array will have four elements.

CREATING ARRAY OBJECTS……

String [] friends=new String[4];

When you create an array object using new, all its elements are initialized for you(memory allote)

You can also create an array like this…….

String[] friends={“SMITH”, “ALLEN”,”SANIT”, “SANJAY”};

TYPES OF ARRAY……

1)SINGLE dimensional array

2)DOUBLE(Multi)dimensional array

SINGLE dimensional……In Single dimensional array having a

             a)Single row and multiple columns(SR-MC)

             b)Single column and multiple rows(SC-MR)

MULTI dimensional ……In multi dimensional array having a

     Multiple rows(more than one row) and Multiple columns(more than one columns)

About Us

Rekha SetiaRekha Setia is a passionate blogger of Extra Computer Notes. if you have any ideas or any request me @