public class HeapQuiz {
int id = 0;
public static void main(String []args) {
int x =0;
HeapQuiz [] hq = new HeapQuiz[5];
while(x <3) {
hq[x] = new HeapQuiz();
hq[x].id =x;
x = x +1;
}
hq[3] = hq[1];
hq[4] = hq[1];
hq[3] = null;
hq[4] = hq[0];
hq[0] = hq[3];
hq[3] = hq[2];
hq[2] = hq[0];
System.out.println(hq[3]); }
}
위와 같은 코드가 있는 상황에서
reference variable 과 HeapQuiz object를 연결하라는 문제가 있습니다.
reference variable는
hq[0]
hq[1]
hq[2]
hq[3]
hq[4]
가 있고
HeapQuiz에는
id = 0
id = 1
id =2
가 있습니다.
둘을 어떻게 연결시켜야 할지 몰라서 질문드립니다.
int id =0; 이라는 조건을 준 이유도 궁금합니다.
고수분들 도와주세요