Saturday, 16 July 2016

java - what is the difference between pass by reference and call by reference?



what is the difference between pass by reference and call by reference in java ?


Answer



Java does not pass any variables by reference.



It is tempting to think of objects being passed by reference in Java -- but harmful. Variables of object type are references. When passed, they are passed by value.




In other languages, pass-by-reference and call-by-reference are the same thing.



Edit: More detail is provided in the existing stackoverflow question "Is Java pass by reference?" (Spoiler: No.)


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...