SCJP1.4
"Continuous effort - not strength or intelligence - is the key to unlocking our potential."
*Winston Churchill
Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
Why the above code prints false?Does equal method print true only for String objects(ofcourse of same value)?
Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Originally posted by liborio:
For variables of object type, the "value" is taken as the reference to the object - typically, the memory address. you should not use this operators to compare the contents of objects, such as strings, because they will return true if two references refer to the same object, rather then if the two objects have an equivalent meaning.
From the RHE book
SCJP1.4
"Continuous effort - not strength or intelligence - is the key to unlocking our potential."
*Winston Churchill
Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
StringBody doesn't.
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Ron Newman - SCJP 1.2 (100%, 7 August 2002)
SCJP1.4
"Continuous effort - not strength or intelligence - is the key to unlocking our potential."
*Winston Churchill
Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Originally posted by Ron Newman:
...
I don't see the mutability as a real barrier to doing this right. StringBuffer.hashCode() could just return toString().hashCode() .
SCJP2. Please Indent your code using UBB Code
You ridiculous clown, did you think you could get away with it? This is my favorite tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|