Gunny Jennings wrote:Example 2: Objects are passed by reference
Murach are capable of far better than that.
Gunny Jennings wrote: . . .
When a primitive type is passed to a method, it is passed by value. That means the method can't change the value of the variable itself. Instead, the method must return a new value that gets stored in the variable.
When a reference type (an object) is passed to a method, it is passed by reference. That means that the method can change the data in the object itself, so a new value doesn't need to be returned by the method.