class HeapQuiz{
int id=0;//Instance Variable;
public static void main(String[] args){
int x=0;
HeapQuiz[] h=new HeapQuiz[5];//ARRAY ref variable element is h
while(x<3)
{
h[x]=new HeapQuiz(); //Object creating to excess elemnt
h[x].id=x; // to set array element from reference variable
//h[x] is remote control; (.) is like button
x=x+1;
}
System.out.println("BEFORE \n Ref var. Array value -> i.e., h");
System.out.println("Element at index 0 -> " +h[0] );
System.out.println("Element at index 1 -> "+h[1] );
System.out.println("Element at index 2 -> "+h[2] );
System.out.println("Element at index 3 -> "+h[3] );
System.out.println("Element at index 4 -> "+h[4] );
h[3]=h[1];
h[4]=h[1];
h[3]=null;
h[4]=h[0];
h[0]=h[3];
h[3]=h[2];
h[2]=h[0];
System.out.println("AFTER \n Ref var. Array value -> i.e., h");
System.out.println("Element at index 0 -> "+h[0] );
System.out.println("Element at index 1 -> "+h[1] );
System.out.println("Element at index 2 -> "+h[2] );
System.out.println("Element at index 3 -> "+h[3] );
System.out.println("Element at index 4 -> "+h[4] );
}
}