Pass-by-value Semantics in Java Applications
By Peter Haggar2003-11-24
Pass-by-value semantics in Java applications
A few months ago, developerWorks posted some excerpts from my book, Practical Java, published by Addison-Wesley. I will initially use this column on developerWorks to answer some questions asked by readers and to respond to various comments about the excerpts.
The excerpt Understanding that parameters are passed by value and not by reference described the one and only parameter-passing mechanism in Java applications, pass by value. It was written to debunk the commonly held myth that Java applications pass parameters by reference, to avoid common programming mistakes that result from relying on pass-by-reference behavior.
Some of the feedback on this excerpt suggested that I was confusing the issue or was altogether wrong about it. Many of the readers who disagreed with me used the C++ language as an example. Therefore, in this column, I will use C++ and Java applications to further clarify the facts.
Tutorial Pages:
» Pass-by-value semantics in Java applications
» The key point
» Parameter passing in C++ and Java applications
» Examples
» Writing a swap method
» Resources
First published by IBM DeveloperWorks
