On Thu, 12 Aug 1999, Shiraz Wasim Zaidi wrote:

> Hi!,
>
> No, It wont work....
>
> The result will be null . Method parameters variables are created
> when a method is invoked and its value is initialized with the
> method argument.  i.e copy of actual argument is passed not the
> actual argument.

Well, the code will "work", in that temp will have the right value
after the call.  However, this is almost a matter of luck, as the code
is very poorly written -- here's a cleaned up version:

...
String temp = process_me();

out.println(temp);
...


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

There's no reason to initialize temp to null, and no reason for
process_me to have a parameter.

It's also not quite clear what the original poster wants.  I echo the
suggestion that he read up on more basic Java stuff, and then some
servlet stuff, instead of posting such questions to this list.


> -----Original Message-----
> From: Chris Pratt <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
> Date: Thursday, August 12, 1999 7:32 PM
> Subject: Re: will this code work?
>
> >Yes it will.  But that is an awefully convoluted way of doing
> >out.println("my name");  At this point I would suggest you read through the
> >Java Tutorial on Sun's site, it's free and it will teach you these
> >rudimentary things.
> >    (*Chris*)
> >
> >----- Original Message -----
> >From: Duke Martin <[EMAIL PROTECTED]>
> >To: <[EMAIL PROTECTED]>
> >Sent: Thursday, August 12, 1999 4:57 PM
> >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?
> >>
> >
>

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