On Thu, 12 Aug 1999, Duke Martin wrote:
> hi,
>
> what if i have:
>
> String s = null;
>
> I want to pass the String s to a method:
>
> method1(s);
> public synchronized String method1(String s)
> {
> .
> .
> return s;
> }
> Inside method1 I will assign String s a value. How do I return this value?
> The code snip above doesn't work. any ideas?
Uggh. This is ridiculous. This question is totally off-topic for
this list. By what stretch of the imagination is this a servlet
related question (besides the fact that the subject line says
"servlet")? This isn't even really a Java question, it's a basic
programming question.
I don't want to be list cop, but some of the questions today have just
been so far off-topic of the list.
The problem isn't anything in the method, it's the way you're calling
it, or rather, the way you're (not) using the return value. Try:
s = method1(s);
Further, since s is null entering the method, get rid of the parameter
on the method, initialize it as needed in the method, and just do:
s = method1();
You seem to be expecting Java to use call by reference, which it
doesn't (well, it doesn't use traditional call by reference, as C's
'&' operator allows).
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