Re: ActionEvent Performance Issue
From: Gregory A. Swarthout (gregorys_at_xmission.com)
Date: 12/18/03
- Next message: ak: "Re: Drawing images over tree icons"
- Previous message: Roudet Christophe: "Re: Outlookstyle Side Bar"
- In reply to: Filip Larsen: "Re: ActionEvent Performance Issue"
- Next in thread: Filip Larsen: "Re: ActionEvent Performance Issue"
- Reply: Filip Larsen: "Re: ActionEvent Performance Issue"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 18 Dec 2003 10:00:24 -0800
"Filip Larsen" <filip.larsen@nospam.dk> wrote in message news:<brqoct$2fjm$1@news.cybercity.dk>...
> Gregory A. Swarthout wrote
>
> > > If the strings have been "intern"ed using the
> > > String.intern() method, then you can safely use == to compare them.
> >
> > Not necessarily. Check out
> >
> http://www.javaworld.com/javaworld/javaqa/2003-12/01-qa-1212-intern.html
> > for the explanation on why this can't always be counted on.
>
> Would you please explain where in the article it is claimed that
> intern'ed strings not always can be compared with the == operator?
"As you can see, s1 is interned and later garbage collected. s2
represents the same string value but is re-interned as a new object.
In other words, Java does not prevent the "same" interned String from
being different objects at different times."
Since == compares object references, not the contents of the string,
it can return false under specific, deterministic situations. Why
compare Strings by a method that *almost* always returns the same
value as .equals() when .equals() itself returns the results you need
100% of the time?
Greg
- Next message: ak: "Re: Drawing images over tree icons"
- Previous message: Roudet Christophe: "Re: Outlookstyle Side Bar"
- In reply to: Filip Larsen: "Re: ActionEvent Performance Issue"
- Next in thread: Filip Larsen: "Re: ActionEvent Performance Issue"
- Reply: Filip Larsen: "Re: ActionEvent Performance Issue"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|