Originally posted by Khalid A. Mughal:
int[] a = {10, 20, 30, 40, 50}; // an array of int
int index = 4;
a[index] = index = 2;
After the execution of this code, the value of index is 2.
What is the value of a[2], i.e. a[index]? 30. :-)
All the best.
-- khalid mughal
I got confused as well, Mr.Mughal. I tried to
test it in a program...
What I understand is that the number 2 is assigned to index and index becomes 2. After that a[index], which is a[2], is assigned to the value of index, which is 2, isn�t it?
It�s kinda comfusion�
Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0