Are hashCodes unique for Strings?
- by Batty
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.