array of objects in java

Java
obj array[] = new obj[10];

for (int i = 0; i < array.length; i++) {
  array[i] = new obj(i);
}public class MainClass
{  
    public static void main(String args[])
    {
        System.out.println("Hello, World!");
        //step1 : first create array of 10 elements that holds object addresses.
        Emp[] employees = new Emp[10];
        //step2 : now create objects in a loop.
        for(int i=0; i<employees.length; i++){
            employees[i] = new Emp(i+1);//this will call constructor.
        }
    }
}

class Emp{
    int eno;
    public Emp(int no){
        eno = no;
        System.out.println("emp constructor called..eno is.."+eno);
    }
}//create class
class enemies {
   int marks;
}
//create object array
enemies[] enemiesArray = new enemies[7];
//assign value to object
enemiesArray[5] = new enemies(95);A[] arr = new A[4];
for (int i = 0; i < 4; i++) {
    arr[i] = new A();
}

//test
Source

Also in Java: