Re: "some text".equals(someString)
--- "E.L. Willighagen" <egonw@sci.kun.nl> wrote:
>
> Hi all,
>
> can anyone tell me the difference (performance etc) between:
>
> 1. String someString = "text"
> if ("some text".equals(someString)) {};
>
> and
>
> 2. String someString = "text"
> if (someString.equals("some text")) {};
>
Hi
I don't know if there's a difference in performance (and it will
certainly depend of the JVM implementation).
Personnaly I use the first alternative as it permits null values for
someString without throwing a NullPointerException. It's also possible
to have someString that's not declared as a String (you don't need to
cast it, and hence avoid a ClassCastException).
I hope I answered your question...
Francois.
=====
Francois BOTTIN
--
"How kind," the PFY sighs. "But where will I go?"
"Somewhere where they know nothing about computing...
where they wouldn't know a RAM chip from a potato chip!"
"But I don't want to visit Microsoft!" he whines.
The BOFH 1998 - Simon Travaglia (bofh.ntk.net)
__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
Reply to: