Does Java use pass by value or pass by reference semantics when passing parameters to methods?

John Mitchell

Java passes parameters to methods using pass by value semantics. That is, a copy of the value of each of the specified arguments to the method call is passed to the method as its parameters.

Note very clearly that a lot of people confuse the "reference" terminology with respect to Java's references to objects and pass by reference calling semantics. The fact is, in dealing with Java's references to objects, a copy of the reference's value is what is passed to the method -- it's passed by value. This is, for example, why you cannot mutate the (original, caller's) reference to the object from inside the called method.

In another conversation, Joe Sam points out that Peter Hagaar wrote an article about Understanding that parameters are passed by value and not by reference.