1.
Array in Java
In Java and other programming languages, there is one
capability wherein we can use one variable to store a list of
data and manipulate them more efficiently. This type of variable
is called an array.
An array stores multiple data items of the same data type,
in a contiguous block of memory, divided into a number of slots.
2. Types of Array and Syntax
The different types of arrays are single dimensional, two
dimensional and multidimensional arrays. They can be declared
in java as follows:
1)for single dimensional:
int x[]=new int[5];
2)for 2-d array:
int x[][]=new int[5][4];
3)for multidimensional array:
combination of both 1 and 2nd declaration is allowed.
3. Sample Program
1 public class ArraySample{
2 public static void main( String[] args ){
3 int[] ages = new int[100];
4 for( int i=0; i<100; i++ ){
5 System.out.print( ages[i] );
6}
7}
8}