Equals method

The equals method applied to a String, however that String was created, performs a character by character comparison.

I was reading above concept from link


I was not clear on what it means by 'performs a character by character comparison.'

Any ideas, resources,sample code,links,  highly appreciated. thanks in advance.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

"Chararcter by character compatison " - it is simple

let's say we compare





we comaper first character in both - they are "c" - indetical
second carcahcter - "o" - identical
third ccharcater "l" - identical
fourth character  in "colonel" - it would be "o" , in "column" - it would be "u"
"o" is not the same as "u" - so these two strings are different

if we would have come to the end of the string and all charchters
are matching - those strings would be equal,
that is what method   equals(String) performs

gudii9Author Commented:
does it different from absolute comparison. what is shallow comparison. What are different kinds of comparisons available. Please advise

This is about shallow and deep equals :

In general I would not go too much into that detail about deep and shallow.

About equals it is good to know how override this method
and that string should be compared only using this method

comparison of strings charcater by character as far as I understand
is as deep as possible - there is no deeper level in the String
which we do not check.

OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

gudii9Author Commented:
hashcode() just compares the reference variables of the object reference right unlike each and every character. please advise
hashcode() does not compare any objects.
hashcode() returns number which is unique for the object. But as opposed to equals it does not return boolean and it does not mention second object.
Read these excerpts for Java API for hashcode()
and for equals()

You'll first see my point that hashcode() is a function of just one object, so by itself it does not compare  two objects, like equals(Object o), which in general situation uses two objects - the object on which this method is running and the object which is supplied by the argument

Another distiction that hashcode() returns integer
and equals() returns boolean

Otherwise there are of course some things to think about in these


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.