Overview Of Single Dimensional Arrays

Introduction

We can say that Array is a bucket that contains number of buckets which have some values. Arrays store multiple variables of same type in data structure. Arrays belong to reference type.

Explanation:

  1. //We declear an array of size 5.  
  2. int[ ] numbers = new int[5];   
  3. //Now initialize the values of individual indexes of array.  
  4. number[0] = 12;  
  5. number[1] = 15;  
  6. number[2] = 18;  
  7. number[3] = 19;  
  8. number[4] = 26;  
We can declare & initialize an array at the same time.
  1. Int[] numbers = new int[5];   
  2. {  
  3.     12,  
  4.     15,  
  5.     65,  
  6.     98,  
  7.     78  
  8. };  
Array’s index start from zero and then continue.

It is must that the value which are stored in arrays have the  same type.

It is incorrect that the data stored in array belongs to different types.

It is necessary that the number of values between the squire brackets [ ] must match the values stored in Arrays. We discussed above is single dimensional Arrays.

Arrays belong to System class. There are three types of Arrays:

 

  1. Single dimensional Arrays.
  2. Multi dimensional Arrays.
  3. Jagged Arrays.

The multi-dimensional arrays & jagged arrays will be discussed in the next blog.