Declaration of Array:
Array in Java may be declared in two forms :
1. type arrayname[ ];
2. type [ ] arrayname;
After declaring an array, we need to create it in the memory. Java allows us to create arrays using new operator only, as shown below :
Arrayname = new type[size];
number = new int;
average = new float;These lines create necessary memory locations for the arrays number and average and designate them as int and float respectively. Now the variable number refers to an array of 5 integers and average refers to an array of 10 floating point values.