Suppose I am writing a method foo(int i)
in Java.
Since i
is passed by value it is safe to change it in foo
. For example
Since i is passed by value it is safe to change it
foo()
It is absolutely safe even when you pass an object reference because they are local: i.e., assigning a new reference to the local reference will not have any impact on the original reference in the calling code
It's your personal choice. However i would not change the argument values as one might loose the track of the actual value passed in to this method.