when you pass a parameter in
java it's by value, for primitives you're passing a copy of the primitive. For objects you're passing a copy of the REFERENCE to the object. Changing the copy of a doesn't change a, but the copy of the reference to b still points to the actual b object. For a more consistent example make change:
Originally posted by sindura kapur:
according to me the output of following code
should be 10 10 BUT ACTUALLY IT IS 0 10.can anyone explain me how and why is that output changes b but not a?
[HENRY: Added code tags]
[ July 26, 2008: Message edited by: Henry Wong ]
[ July 27, 2008: Message edited by: gebuh Boose ]