On Wed, 15 Dec 1999, Kito Mann wrote:

> Sushil,
>
> First, this question is way off topic.

Agreed.


> All Objecs in Java are passed by reference. Objects include Strings
> and Arrays, but not the primitive types: (ints, chars, longs,
> floats, etc.).
[ ... ]

This has been discussed before on this list, and FWIW, this is not
technically true.  Java only does pass by value; but it just so
happens that when an Object is a function argument, the value that is
passed is its reference.  One might argue that this is a meaningless
distinction, but it does mean that Java does not behave according to
the technical definition of pass by reference (e.g. you can't write a
swap function the way you can in languages that do pass by reference).
But it does allow you to write functions that can modify their Object
arguments, in certain cases.  Strings, however, are immutable
(i.e. unchangable), so that is not one of the cases.

Now, it's unclear what exactly the original poster is trying to do, so
without more details, I don't know how to provide this information to
their situation.



> Please respond to [EMAIL PROTECTED]
> To:   [EMAIL PROTECTED]
> cc:    (bcc: Kito Mann/PSG/Prudential)
> Subject:  Parameters passed by reference

> Hi,
>
> I would like to know that how can we pass a variable by REFERENCE to a
> method within the same class.
>
> I have read that in order to pass by reference, we have to pass the object
> itself.  But in my case I have to pass a variable say string to a method
> inside the same class.
>
> Thanks,
>
> Sushil
> Email:   [EMAIL PROTECTED]   (Personal)
>             [EMAIL PROTECTED]  (Official)
>

Milt Epstein
Research Programmer
Software/Systems Development Group
Computing and Communications Services Office (CCSO)
University of Illinois at Urbana-Champaign (UIUC)
[EMAIL PROTECTED]

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to