On Fri, 13 Aug 1999, Andy Bailey wrote:

> ----- Original Message -----
> From: Duke Martin <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, August 13, 1999 1:57 AM
> Subject: will this code work?
>
> > String temp = null;
> > temp = process_me(temp);
> >
> > out.println(temp);
> >
> > public String process_me(String temp)
> > {
> > temp = "my name";
> > return temp;
> > }
> >
> > I would like to this the output of this servlet to print "my name"
> > to the screen.  Will this work?
>
> Yes.
>
> Returning the string is redundant but makes you code absolutely
> clear for others reading it.

*Actually*, returning the string is *essential*, and is about the only
thing in this totally convoluted code that is on target (the other
being the assignment of temp to the result of process_me).  Try it
without it (cleaning up the resulting compiler problems of course),
and you will see that it won't work.

Here is what this code should be distilled down to:

String temp = process_me();
out.println(temp);

public String process_me()
{
return "my name";
}


The following will *not* work:

String temp = null;
process_me(temp);
out.println(temp);

public String process_me(String temp)
{
temp = "my name";
return temp;
}


Nor will:

String temp = null;
process_me(temp);
out.println(temp);

public void process_me(String temp)
{
temp = "my name";
}


[ ... ]
> Amazing load of spam for a simple question really

Yes, really, which you've only added to.

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