Re: Call by reference in Java?
From: Ekim (the.newsletter_at_gmx.net)
Date: 02/25/04
- Next message: Richard Haygreen: "Swing button to open new JFrame"
- Previous message: Andrew Thompson: "Re: HashMap, getValueByKey and getKeyByValue"
- In reply to: Collin VanDyck: "Re: Call by reference in Java?"
- Next in thread: Bjorn Abelli: "Re: Call by reference in Java?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 25 Feb 2004 22:48:57 +0100
okay,
thx to all of you...I think I got it at last...it already works in my
application!
by ekim
"Collin VanDyck" <thehoppocket@yahoo.com> wrote in message
news:wK6%b.9204730$Id.1533184@news.easynews.com...
> "Ekim" <the.newsletter@gmx.net> wrote in message
> news:c1isov$1ivn18$1@ID-222835.news.uni-berlin.de...
> > hmm, I'm not quite sure about it.
> > maybe you could give me an example according to my procedure-call below?
> >
> > thx,
> > ekim
> >
>
> Ok
>
> Your procedure was
>
> public void checkParameter(String strPreisProLiter, String strAnzahlLiter,
> String strPreis, String strGesamtkilometer)
> {.....}
>
> The problem is that each one of those Strings you are passing in are not
> actually the Strings themselves, but instead copies of the pointers to the
> strings (if you are more comfortable with C terminology).
>
> Whatever you do to those pointers to Strings in your function, you will
only
> be modifying copies of the pointers to the original Strings.
>
> If you are desiring to change the values of the Strings within the
function
> and have those changes be visible outside of the function, you are going
to
> need to rethink your approach.
>
> You could have your function return a Collection of new Strings that
> correspond to the changed values, or return a struct-like data structure
> that contained four Strings.
>
> Can you specify exactly what your desired effect would be? I think I'm
> getting unnecessarily complex here :)
>
> -CV
>
>
- Next message: Richard Haygreen: "Swing button to open new JFrame"
- Previous message: Andrew Thompson: "Re: HashMap, getValueByKey and getKeyByValue"
- In reply to: Collin VanDyck: "Re: Call by reference in Java?"
- Next in thread: Bjorn Abelli: "Re: Call by reference in Java?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|