To change your membership options, refer to:----Original Message-----
From: Madhav Vodnala [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 31, 2002 3:59 PM
To: JDJList
Subject: [jdjlist] Re: Java : pass by reference???Hi ShankarHere is my take on 'pass by reference' theory.Here are the absolute statements about 'pass by reference'1) Pass by reference works for all Classes, except Strings and arrays.
[Shankar] Pass by reference works for all objects(incl arrays which are also objectsbe it even primitive arrays.as by definition anything on the heap is an object and anything "new"edis on the heap) And by inlining the code in the methods that am calling amable to change the value of the variables or objects to be precise. So why not frominside a method?
SO, the theory isIf you assign the new object (created with new ) to the function argument (which refers to the calling method variable) and modify itscontent, it doesnt modify the calling method's variable value, irrespective of whether calling method's variable is passed by value or passed byreference.[Shankar] this is wot i infered from the behaviour of the code So then coming back to the "pass by reference"for objects. This behaviour says its a "pass by value" and "pass by reference" correct?Another interesting fact is a swap method (like the one u write in C to swap an integer value)cannot be written in Java just for this one small behavioural issue of the language. I dont knowif its an issue for starters. u cant just swap two strings inside a called method cos of this.-Madhav
http://www.sys-con.com/java/list.cfm
