Java Array Example
Chapter:
Miscellaneous
Last Updated:
21-07-2016 18:31:56 UTC
Program:
/* ............... START ............... */
public class JavaArrayExample {
public static void main(String args[]) {
int a[] = new int[3];
a[0] = 40;// initialization
a[1] = 20;
a[2] = 22;
for (int i = 0; i < a.length; i++)
System.out.println(a[i]);
}
}
/* ............... END ............... */
Output
Notes:
-
Java array is an object the contains elements of similar data type.
- Java array can store only fixed set of elements.
- Array in java is index based, first element of the array is stored at 0 index.
Tags
Array, Java