Rasul Patrick wrote:I'm little bit confused...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Rasul Patrick wrote:
Primitive arguments, such as an int or a double, are passed into methods by value. This means that any changes to the values of the parameters exist only within the scope of the method. When the method returns, the parameters are gone and any changes to them are lost.
Rasul Patrick wrote:
Primitive arguments, such as an int or a double, are passed into methods by value. This means that any changes to the values of the parameters exist only within the scope of the method. When the method returns, the parameters are gone and any changes to them are lost.
Reference data type parameters, such as objects, are also passed into methods by value.
This means that when the method returns, the passed-in reference stil references the same object as before.
However, the values of the object's fields can be changed in the method, if they have the proper access level.
Winston Gutkowski wrote:
Rasul Patrick wrote:I'm little bit confused...
The fact is that Java always passes by value; the only difference between reference types and primitives is that, for the former, its the reference that is passed by value.
Thus you cannot reassign the value of a passed reference variable,
but you can most certainly change the object that it points to if it's mutable (and the presence of a 'set...' method is a bit of a giveaway there).
Consider Paul's rocket mass heater. |