ia.clone() makes a new Object , with type same as ia , int[][] tht is , and with state same as ia , { { 1 , 2}, null } , tht is , and resturns a reference to this new object , which is stored in ja
now
ia == ja compare these object-references , (or array-references ) with each other , and because they are not equal , it returns false
ia[0] == ja[0] && ia[1] == ja[1] compares the values of the array-elements , which are equal , because 'ja' is a clone of 'ia' ( as per previous explanation ) , so it returns true
the trick is when array dimensions are increased from 1 , means multi-dimensional arrays , then instead of storing the whole array as element ( as in array of array ) , only reference to it is stored ,
like for , first element of given array ,
{ 1 , 2 ) , the ia[0] only conatins a reference to this array in heap , and while cloning , only this reference is copied , new copy of whole
{ 1 , 2 ) is not made , so
ia[0]==ja[0] returns true , because this is effectively comparing reference to same element ( {1,2} tht is )
well..i knw is hard to understand with my explanation , so i quote a line from JLS
A clone of a multidimensional array is shallow, which is to say that it creates only a single new array. Subarrays are shared
refer u to section 10.7 of JLS 2nd ed for more on this
------------------
Gagan (/^_^\)