Example of single dimensional java array

Java Programming Language / Array in java

1211

Program:

public class ArrayExample {

   public static void main(String args[]){

   int a[]=new int[5];//declaration and instantiation
   a[0]=10;//initialization index 0
   a[1]=20;//initialization index 1
   a[2]=30;//initialization index 2
   a[3]=40;//initialization index 3
   a[4]=50;//initialization index 4

   //printing array
   for(int i=0;i<a.length;i++)//length is the property of array
   System.out.println(a[i]);

   }
}

Output:

10
20
30
40
50
Press any key to continue . . .

Explanation:

The above program is an example of single dimensional java array

This Particular section is dedicated to Programs only. If you want learn more about Java Programming Language. Then you can visit below links to get more depth on this subject.