java array objects code example
Example 1: how to create an array in java
int[] array1 = new int[5];
String[] array2 = new String[5]
double[] array3 = new double[5]
Example 2: java array object
Class obj[]= new Class[array_length]
Example 3: java class array of objects
public class MainClass
{
public static void main(String args[])
{
System.out.println("Hello, World!");
Emp[] employees = new Emp[10];
for(int i=0; i<employees.length; i++){
employees[i] = new Emp(i+1);
}
}
}
class Emp{
int eno;
public Emp(int no){
eno = no;
System.out.println("emp constructor called..eno is.."+eno);
}
}