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//method 1
2int[] age = new int[3];
3 age[0] = 1;
4 age[1] = 3;
5 age[2] = 6;
6
7 for (int i=0; i < 3; i++)
8 System.out.println(age[i]);
9
10//method 2
11 int[] num = {3,3,5};
12 //int num[] = {3,3,5}; also works the same
13
14 System.out.println(num[0]);
1//you can do it like this
2int[] arr = {10, 20, 30, 40};
3//or this
4int arr = new int[4];