The value being passed is a copy of the reference.
Within main, the original reference is assigned to the local variable pbv. Within callme, a copy of that reference (i.e., a value) is assigned to the local variable ppbv. However, both of these point to the same object. So either reference can be used to change the object's state, and this change will be "visible" through the other reference.
On the other hand, if you reassigned ppbv to point to a different object...
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
Hello,Rex Isaacs: Acturally,when you get "PassbyValue pbv = new PassbyValue(100,200);" that create an object and initialize the two variable and set Price=100 and Value=200;but when get "callme()" the reference is the "object",following
Here after calling the method callme() with pbv as the object, the value of Price and Value had been reset, so it prints 300 and 400 instead of 100,200.
If I got any wrong ,please tell me anyone about my answer include my caluse syntax.
Head first Servlet and JSP
Rex Isaacs
Greenhorn
Joined: Jul 26, 2003
Posts: 8
posted
0
Thanks all for your valuable replies to make me understand the concept.
I got it now. [ April 30, 2007: Message edited by: Rex Isaacs ]