Re: call by reference
- From: "rosty" <dima.hristov@xxxxxxxxx>
- Date: Sat, 2 Jul 2005 13:51:28 +0300
Thank you all! That's exactly what i was saying, but they would just not
listen. I'l show them this on monday. We'll see.
"Chris Smith" <cdsmith@xxxxxxx> wrote in message
news:MPG.1d2fc52264ee6b3989a3e@xxxxxxxxxxxxxxxxxxx
> George Cherry <GWCherryHatesGreenEggsAndSpam@xxxxxxxxxxxx> wrote:
>> Chris, I'm afraid your example will give rosty the wrong
>> notion that a called method can't change an object
>> when you pass the method the value of a reference
>> variable referring to the object?
>
> Only if rosty doesn't understand what's going on... which he said he
> did. The point is that assigning to the formal parameter does not
> affect the value of the actual parameter. In your code:
>
>
>> private static void change(int[] a) {
>> a[0] = 4;
>> a[1] = 5;
>> a[2] = 6;
>> }
>
> In this case, you never assign to the formal parameter, so it doesn't
> even matter if the parameter passing is by reference or by value. The
> parameter just happens to identify some shared state, and you've
> modified the shared state. This is exactly the same situation as my
> "example 2" in the original post, and it doesn't demonstrate pass by
> reference.
>
> --
> www.designacourse.com
> The Easiest Way To Train Anyone... Anywhere.
>
> Chris Smith - Lead Software Developer/Technical Trainer
> MindIQ Corporation
.
- References:
- call by reference
- From: rosty
- Re: call by reference
- From: Chris Smith
- Re: call by reference
- From: George Cherry
- Re: call by reference
- From: Chris Smith
- call by reference
- Prev by Date: Re: Is there problem with Java and transparent images?
- Next by Date: Re: Is there problem with Java and transparent images?
- Previous by thread: Re: call by reference
- Next by thread: Re: call by reference
- Index(es):
Relevant Pages
|