I know that Java passes objects by value, but you can still do stuff with an object that is being passed to the function. So I'm not sure which way is more preferable and, um, cleaner, if I want to do something to an object in my function. Should I just change it like this:
public void foo(Person person){
person.setName("John");
}
or should I explicitly return the object like this:
public Person foo(Person person){
person.setName("John");
return person;
}
The result is the same in both cases, but which one is safer? Or is there no difference?