Array:-
An array is an index collection of fixed number of homogeneous data elements.
The main advantage of an array is we can represent a huge number of elements by a single variable.
But the main disadvantage of an array is it is fixed in size so that once the array is created then there is no chance of increasing the size of the array based on our requirement.
Hence to use an array, we should know the size in advance.
Array Declaration;-
How to declare an array ?
Let's see in how many ways we can declare an array.
1-D Array Declaration:-
int [ ] x; (Recommended to use)
int [ ]x;
int x[ ];
Above all three declaration of the 1-D array is valid.If we are using other than this then we will get compile time error.
2-D Array Declaration:-
int [ ][ ] x;
int [ ][ ]x;
int x[ ][ ];
int [ ] x [ ];
int [ ] [ ]x;
int [ ]x [ ];
Above all declaration of 2-D array is valid.If we are using other than this than we will get compile time error.
3-D Array Declaration:-