Article View: borland.public.jbuilder.java.swing
Article #8983Re: Dialog Data Exchange
From: John P. McGrath
Date: Tue, 20 Jun 2000 00:00
Date: Tue, 20 Jun 2000 00:00
26 lines
1356 bytes
1356 bytes
On Tue, 20 Jun 2000 10:59:33 -0700, Jon C. Creyts wrote:
> public boolean showDialog(String transfer) {
> ok = false; //ok is a boolean changed to true if OK button
> is pressed
> show();
> if (ok) {
> transfer = transfer.concat(", ModifiedInDialog2");
> }
> return ok;
> }
This code will not work, since the concat() method does not modify the
string that is passed to it. Neither does any other method modify a
string, since strings are immutable. Instead, it creates a new string
that contains the argument appended to it.
Your code then modifies the argument variable "transfer", which is a
reference to a string. This changes the "transfer" variable to refer to
the new string, but it does not change the variable that was passed to
the showDialog() method.
--
John P. McGrath
<JPMcGrath@fast.net>
<jpm@nscs.fast.net>
Technical Details
Message-ID:
<MPG.13b9ff0d6a007409899df@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<394FB104.83277EB5@newton.berkeley.edu>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,3e33a8a99f1c0992 X-Google-Attributes: gid111d45,public From: John P. McGrath <JPMcGrath@fast.net> Subject: Re: Dialog Data Exchange Date: 2000/06/20 Message-ID: <MPG.13b9ff0d6a007409899df@forums.borland.com> X-Deja-AN: 637061033 References: <394FB104.83277EB5@newton.berkeley.edu> Organization: Another Netscape Collabra Server User Newsgroups: borland.public.jbuilder.java.swing