Dan Acuff
,
Ranch Hand
Apr 01, 2010 14:08:15
Shouldn't the code I have written work so far as the cm_pageName getting reset to HOME or LIST ?
What am I doing wrong in resetting cm_pageName?
I am just getting blank values and I have tested the value of cm_pageName to be one of the 2 strings shown.
Thanks,
Dan
Rob Spoor
,
Sheriff
staff
Apr 01, 2010 14:30:35
Never use == for String comparison - use the equals method instead.
Dan Acuff
,
Ranch Hand
Apr 01, 2010 14:52:39
Thanks a lot~
Looks like this for the record.
Sita Marivada
,
Greenhorn
Apr 01, 2010 14:53:54
== is used to compare the values of primitive typed variables and the memory location of Objects.
equals is used to compare the content of the two objects.
== is normally much faster than equals since it just checks the memory location of two objects.
Dan Acuff
,
Ranch Hand
Apr 01, 2010 14:57:08
Oh I see.. and since String is not a primitive variable type, the equals method is better.
marc weber
,
Sheriff
staff
Apr 01, 2010 15:07:06
Dan Acuff wrote: Oh I see.. and since String is not a primitive variable type, the equals method is better.
That's correct. And using == to compare Strings is a little more complicated than with most objects because of the String pool. See Strings Literally .
David Newton
,
Author
Apr 01, 2010 18:03:16
On line 2 there is no reason to create a new string.
Lookout! Runaway whale! Hide behind this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com