Java is always pass-by-value. The difficult thing can be to understand that Java passes objects as references passed by value.
It goes like this:
It goes like this:
public void foo(Dog d) {
d.name.equals("Max"); // true
d = new Dog("Fifi");
d.name.equals("Fifi"); // true
}
Dog aDog = new Dog("Max");
foo(aDog);
aDog.name.equals("Max"); // true