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// datatype var = new datatype[size]
2
3int[] arr = new int[10];
4// OR
5int arr[] = new int[10];
1Size is fixed
2It supports both primitives and objects
3Can be also multi-dimensional
1int intArray[]; //declaring array
2intArray = new int[10]; // allocating memory to array
3intArray[0] = 10; // Adding elements to the array
4System.out.println(intArray[0]); // Accessing elements of array
1//Metodo 1
2type nome = new type[n];
3
4//Metodo 2
5type nome[];
6nome = new type[n];