posted 19 years ago
Remember that array implicitly implements Cloneable and Serializable interface
Another thing to remember is that all array of prmitives extends Object class and all arrays of references extends Object[] class
Now regarding ur problem,
This what is the intended meaning when u do a clone on the given array
Object[] obj = (Object[])a.clone(); -----:
Now when u do :
1st pass of for loop---> int[] ia = (int[])obj[0]// which is {1,2}
SOP(ia[0]) // which is 1
2nd pass of for loop---> int[] ia = (int[])obj[1]// which is {0,1,2}
SOP(ia[1]) // which is 1
3rd pass of for loop---> int[] ia = (int[])obj[2]// which is {-1,0,2}
SOP(ia[2]) // which is 2
Hope u r clear now