On Friday 21 June 2002 09:25 am, Alpha Zenon Sanchez wrote:
>
> BTW...my gut instinct tells me that the second example
>
> 'if (a.equals("something")){
>
> ---instructions----
>
> }
>
> will compile and work....I've seen this example
> before,
> but not sure why a.equals works rather than a ==
>
> =====
> Thanks,
> Alpha Zenon Sanchez
>
"a.equls()" tests to see if the objects are equal. Two diff. objects are
equal.
"==" will tell you if two refrences point to the same object.
String a = "foo"
String b = "foo"
if (a.equals(b)) // true
if (a == b) // false
b = a
if (a == b) // true
Hope this helps.
- --
- -------------------------------------------------
Isaac Sparrow
Staff Engineer
VisiComp, Inc.
http://www.visicomp.com
GnuPG Key Fingerprint:
1060 5A07 F6EC B2B3 9AAA 3EA5 7B79 EFE1 6397 4F47
Get my public key at:
http://www.concentric.net/~issparow
'Mounten' wird fuer drei Dinge benutzt: 'Aufsitzen' auf Pferde, 'einklinken'
von Festplatten in Dateisysteme, und, nun, 'besteigen' beim Sex.
(Christa Keil in a German posting: "Mounting is used for three things:
climbing on a horse, linking in a hard disk unit in data systems, and, well,
mounting during sex".)