Site hosted by Angelfire.com: Build your free website today!
 

Parameters - Pass by Value

In Java methods, arguments are passed by value. When invoked, the method receives the value of the variable passed in.

  • When the argument is of primitive type, pass-by-value means that the method cannot change its value.

  • When the argument is of reference type, pass-by-value means that the method cannot change the object reference, but can invoke the object's methods and modify the accessible variables within the object.

Note

A copy of the value of the variable is make avaiable to the method; changes to the copy do not affect the origninal value in the calling method.

Article: Cup Size -- a story about variables www.javaranch.com