As we declare a variable in Java, An Array variable is declared the same way. Array variable has a type and a valid Java identifier i.e. the array's type and the array's name. By type we mean the type of elements contained in an array. To represent the variable as an Array, we use  notation. These two brackets are used to hold the array of a variable.
By array's name, we mean that we can give any name to the array, however it should follow the predefined conventions. Below are the examples which show how to declare an array :-
//declares an array of integers
int matrix; //this is an array of arrays
It is essential to assign memory to an array when we declare it. Memory is assigned to set the size of the declared array. for example:
Here is an example that creates an array that has 5 elements.
We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.
Posted on: May 28, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles