1int intArray[]; //declaring array
2intArray = new int[20]; // allocating memory to array
3//OR
4int[] intArray = new int[20]; // combining both statements in one
1int[] array1 = new int[5]; //int array length 5
2String[] array2 = new String[5] //String array length 5
3double[] array3 = new double[5] // Double array length 5
4
1// Accessing array elements using for loop
2public class AccessingArrayElements
3{
4 public static void main(String[] args)
5 {
6 int[] arrNum = {25, 23, 15, 20, 24};
7 for(int a = 0; a < arrNum.length; a++)
8 {
9 System.out.println(arrNum[a]);
10 }
11 }
12}