Help getting experience
Shawn Rutledge
plug-discuss@lists.plug.phoenix.az.us
Mon, 24 Jun 2002 18:19:48 -0700
On Fri, Jun 21, 2002 at 11:09:44AM -0700, Isaac Sparrow wrote:
> String a = "foo"
> String b = "foo"
>
> if (a.equals(b)) // true
>
> if (a == b) // false
Maybe, but Java can also do string interning, which means that it will
see that you already have "foo", probably don't need another one, and
therefore make them both refer to the same instance. While in general
you should use .equals() (or .equalsIgnoreCase(), also very handy; or a
Collator, for faster comparison of frequently-used strings, or for
alphabetical sorting) to compare strings, if you use intern() on every
String, you can use == to compare them, and it will be a lot faster to
just compare references instead of looking at every character until a
difference is found. But internment (like interrment!) is itself an
expensive operation.
Make sure you know the difference between deprecation and depreciation,
and how to pronounce the two; hate to think of how many programmers I've
met who don't.
--
_______ Shawn T. Rutledge / KB7PWD ecloud@bigfoot.com
(_ | |_) http://ecloud.org kb7pwd@kb7pwd.ampr.org
__) | | \________________________________________________________________