Sonir : This question is a classic example of the passing arguments to a method and the result the method has on the original object. A copy of the reference of the stacks is sent to the method. Think that S1 and S2 containnot the stack itself but some address where the actual stacks reside. Within the method X1 and X2 contain the same addresses as S1 and S2. that is X1 is a copy of S1 and X2 is a copy of S2. x1.push (new Integer ("100")); Using that reference, the first statement modifieds one stack. x2 = x1; This second statement simply changes X2 so that it now points to the same obejct that X1 points to. So after this method is executed, the object pointed to by S1 has changed, while the object pointed to by S2 has not changed at all.
If you draw all this on a piece of paper, similar to the diagrams in the RHE book , it will be much clearer to you. Hope this helps