1obj array[] = new obj[10];
2
3for (int i = 0; i < array.length; i++) {
4 array[i] = new obj(i);
5}
1public class MainClass
2{
3 public static void main(String args[])
4 {
5 System.out.println("Hello, World!");
6 //step1 : first create array of 10 elements that holds object addresses.
7 Emp[] employees = new Emp[10];
8 //step2 : now create objects in a loop.
9 for(int i=0; i<employees.length; i++){
10 employees[i] = new Emp(i+1);//this will call constructor.
11 }
12 }
13}
14
15class Emp{
16 int eno;
17 public Emp(int no){
18 eno = no;
19 System.out.println("emp constructor called..eno is.."+eno);
20 }
21}