Results 1 to 2 of 2
Thread: Pass-by-reference
- 10-19-2009, 03:40 PM #1
Member
- Join Date
- Oct 2009
- Posts
- 2
- Rep Power
- 0
- 10-19-2009, 03:45 PM #2
Everything in Java is passed "by value". Everything.
Pass-by-value
- When an argument is passed to a function, the invoked function gets a copy of the original value.
- The local variable inside the method declaration is not connected to the caller's argument; any changes made to the values of the local variables inside the body of the method will have no effect on the values of the arguments in the method call.
- If the copied value in the local variable happens to be a reference (or "pointer") to an object, the variable can be used to modify the object to which the reference points.
Some people will say incorrectly that objects are passed "by reference." In programming language design, the term pass by reference properly means that when an argument is passed to a function, the invoked function gets a reference to the original value, not a copy of its value. If the function modifies its parameter, the value in the calling code will be changed because the argument and parameter use the same slot in memory.... The Java programming language does not pass objects by reference; it passes object references by value. Because two copies of the same reference refer to the same actual object, changes made through one reference variable are visible through the other. There is exactly one parameter passing mode -- pass by value -- and that helps keep things simple.
-- James Gosling, et al., The Java Programming Language, 4th Edition
http://www.javaranch.com/campfire/StoryPassBy.jspMath problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
Similar Threads
-
Object and reference
By katie in forum New To JavaReplies: 2Last Post: 10-19-2009, 03:45 PM -
creating a reference to a value in a map
By kellykellykelly in forum Advanced JavaReplies: 1Last Post: 02-28-2009, 07:59 AM -
removing reference
By ajith_raj in forum Advanced JavaReplies: 4Last Post: 02-12-2009, 11:46 AM -
pls help me out its critical ...... how can we use an arralylist reference
By raj reddy in forum Advanced JavaReplies: 1Last Post: 04-15-2008, 12:09 PM -
Getting the Object Reference Name
By Deathmonger in forum New To JavaReplies: 2Last Post: 03-12-2008, 02:51 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks