how to make an array in java

Java
//method 1
int[] age = new int[3];
        age[0] = 1;
        age[1] = 3;
        age[2] = 6;

        for (int i=0; i < 3; i++)
            System.out.println(age[i]);

//method 2
        int[] num = {3,3,5};
        //int num[] = {3,3,5}; also works the same

        System.out.println(num[0]);(file name) file name(s) = new (File name)[/*amount*/]
  
  void setup() {
  	for (int i = 0; i < (file name(s)).length; i++) {
    	 
    }
  }int[] array = new int[/*size*/];
// Works for double, char, etc.int intArray[];    //declaring array
intArray = new int[20];  // allocating memory to array
//OR
int[] intArray = new int[20]; // combining both statements in onetype var-name[];
OR
type[] var-name;
int[] array1 = new int[5]; //int array length 5
String[] array2 = new String[5] //String array length 5
double[] array3 = new double[5] // Double array length 5

Source

Also in Java: