Are hashCodes unique for Strings?
Posted
by
Batty
on Stack Overflow
See other posts from Stack Overflow
or by Batty
Published on 2014-06-01T08:02:14Z
Indexed on
2014/06/01
9:25 UTC
Read the original article
Hit count: 113
Recently, I came across a piece of code, where Map<Integer, String>
is used, where Integer
(key) is hashCode
of some string and String
value corresponding to that.
Is this right thing to do? Because now, equals
will not be called for the String
when calling get
. (get
is also done using hashCode()
method on String object.
Or, hashCode(s) are unique for unique Strings?
I checked equals
od String
class. There is logic written for that. I am confused.
© Stack Overflow or respective owner