posted 17 years ago
Hi chandra,
Reference of b is passed to A. So, now a is refering to b. This was my observation.
int[] a = {1,2,3,4};
int[] b = {2,3,1,0};
System.out.println(a[ (a = b) [3] ] ); // prints 1
System.out.println(a[ (a = b) [2] ] ); //prints 2
System.out.println(a[ (a = b) [1] ] ); // prints 4
System.out.println(a[ (a = b) [0] ] ); //prints 3
Here the last element is printed as 3rd element and 3rd element is printed as last element but when you print "A" elements. It prints 2,3,1,0
because it is refering to b.Can anybody tell when the "B" reference is passed to "A" why is it printing like that?