It is common statement that
java pass primitive data by value and it pass Object data by references. More precisely it should say that java pass Object date type a copy of the reference to the object.
In Test, the foo method try to assign the passed reference to refer to new
date. That is OK inside the method. But it is a copy of orignail reference so the original reference still point to the old date it is assigned.
In the Test1, you are not try to chang the passed in reference, but you are
change the state of the object the passed in reference points to. Since both the passed in copy and oringinal reference points to the same object,
that same objects state is changed.
Thanks,<br />Jack Zhou<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS,SCEA