Hi, Clone method creates a copy of the object.so,object 'a' is cloned and is stored in 'obj' array.Now length of 'obj' array is 3.Let us go through the loop now. when i=0, ia=obj[0] so ia,obj[0] refer to a[0]. hence ia[0] is same as a[0][0] which is 1. when i=1 ia=obj[1] ia,obj[1] refer to a[1] so ia[1] is same as a[1][1] which is 1 again. when i=2 ia=obj[2] ia,obj[2] refer to a[2] so ia[2] is same as a[2][2] which is 2 Hope this helps...

deepu Bhalotia
Ranch Hand

Joined: Apr 19, 2005
Posts: 39

posted

0

Hi Haran

Can you explain how the array length is 3? We are making a clone of two dimensional array into one dimensional array.

Thanks Deepak

vinuharan haran
Ranch Hand

Joined: Feb 26, 2005
Posts: 64

posted

0

Hi, The length of array a is 3.so obj.length is also 3.That is 'a' has three elements. Dimensional arrays are considered as array of arrays. Now, a has three elements which are references to other array.So a.length is 3.

a[0] is again a array of 2 elements .so,length of a[0] is 2. length of a[1] and a[2] is 3. Hope this helps...