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:
-
- int[ ] numbers = new int[5];
-
- number[0] = 12;
- number[1] = 15;
- number[2] = 18;
- number[3] = 19;
- number[4] = 26;
We can declare & initialize an array at the same time.
- Int[] numbers = new int[5];
- {
- 12,
- 15,
- 65,
- 98,
- 78
- };
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:
- Single dimensional Arrays.
- Multi dimensional Arrays.
- Jagged Arrays.
The multi-dimensional arrays & jagged arrays will be discussed in the next blog.