zhuzhengyu
Technical User
As we all know,java has two parameter-passing methods while call a function:
1.to primitive type,it use value
2.to object, it use reference.
So here is the question:
when I use a method in a class provided by others,and this function need pass some objects as auguments.So there is possibility that after calling this function,the object's value has been changed.Is there any clean method to avoid this and guarantee the object is same before and after calling the function.
I know one way is:everytime before I use a function,I clone an object.But the way is too tedious and not fesible in reality.
1.to primitive type,it use value
2.to object, it use reference.
So here is the question:
when I use a method in a class provided by others,and this function need pass some objects as auguments.So there is possibility that after calling this function,the object's value has been changed.Is there any clean method to avoid this and guarantee the object is same before and after calling the function.
I know one way is:everytime before I use a function,I clone an object.But the way is too tedious and not fesible in reality.